This script looks how many Clips are left open or close and prints the missing brackets or okay if it matches right.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
use strict; print checkClip("5 (( +3").$/; print checkClip("5 )) +3").$/; print checkClip("5 ((3 -) 8 (4 +) 7)").$/; # check brackets sub checkClip { my $clipcount = 0; while($_[0] =~ /G(.)/g) { ++$clipcount if($1 eq "("); --$clipcount if($1 eq ")"); } if($clipcount == 0){ return("seems good!"); }elsif($clipcount > 0){ return("there are $clipcount open cip too much!"); }elsif($clipcount < 0){ return("there are @{[$clipcount*-1]} close cip too much!"); } } |
And we see how many clips we need to close or open, or if its looks good.
1 2 3 |
there are 2 open cip too much! there are -2 close cip too much! seems good! |