From 729cdbe8c41598aaa70c7c71d708953dd72a6866 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 28 Aug 2021 19:42:31 +0200 Subject: incdec.pm: Return both line and start position I want access to the start position of the number being operated on. This will allow me to determine if point should be moved or not. Refactor everything to accept an array from `incdec()`. --- incdec.bash | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'incdec.bash') diff --git a/incdec.bash b/incdec.bash index d00c140..029d4ea 100644 --- a/incdec.bash +++ b/incdec.bash @@ -67,10 +67,15 @@ sub incdec { $line =~ s/(-?\d+)/$1 + $increment_by/e; } - return $line; + return ($line, $start_position); } -my $output = incdec($line, $increment_by, $point_position, $backward); +my ($output, $start_position) = incdec( + $line, + $increment_by, + $point_position, + $backward +); print $output; ' \ -- \ -- cgit v1.2.3