diff options
Diffstat (limited to 'challenge-018')
| -rw-r--r-- | challenge-018/jaime/perl5/ch-1.pl | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/challenge-018/jaime/perl5/ch-1.pl b/challenge-018/jaime/perl5/ch-1.pl index eeb61845eb..afc6d29993 100644 --- a/challenge-018/jaime/perl5/ch-1.pl +++ b/challenge-018/jaime/perl5/ch-1.pl @@ -6,11 +6,10 @@ my $head = shift; for my $n (reverse 1..(length $head)) { - for my $i (0..((length $head)-$n)) { + SUBSTRING: for my $i (0..((length $head)-$n)) { my $s = substr($head,$i,$n); - if (@ARGV == grep(/$s/,@ARGV)) { - print "$s\n"; - exit; - } + next SUBSTRING unless @ARGV == grep(/$s/,@ARGV); + print "$s\n"; + exit; } } |
