From 463490a1857274ebf5b488c38e1a280a4d9b7669 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 19 Aug 2021 21:49:21 +0200 Subject: incdec: Clean up code from backwards incrementing development --- incdec.pm | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'incdec.pm') diff --git a/incdec.pm b/incdec.pm index a473e30..f13209b 100644 --- a/incdec.pm +++ b/incdec.pm @@ -10,19 +10,12 @@ sub incdec { $is_backward ||= 0; my $start_position = 0; - my @points = (); my $previous_match_start = 0; my $previous_match_end = 0; - print "$line\n"; while ($line =~ /(\d+)/g) { if ($is_backward) { - print "pos[$point_position] -[$-[0]]- +[$+[0]]+\n"; - print "pos[$point_position] -[$previous_match_start]- +[$previous_match_end]+\n"; - # if $point_position < $-[0] - # && previous $+[0] <= $point_position - if ($previous_match_end - 1 <= $point_position && $point_position < $-[0]) { - # if ($-[0] <= $point_position && $point_position < $+[0]) { - print "matched at $-[0];$previous_match_end\n"; + if ($previous_match_end - 1 <= $point_position + && $point_position < $-[0]) { $start_position = $previous_match_start; last; @@ -32,11 +25,11 @@ sub incdec { $previous_match_end = $+[0]; } else { - if ($point_position < $+[0]) { - $start_position = $-[0]; + if ($point_position < $+[0]) { + $start_position = $-[0]; - last; - } + last; + } } } -- cgit v1.2.3