aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-057/yet-ebreo/perl/ch-2.pl8
1 files changed, 6 insertions, 2 deletions
diff --git a/challenge-057/yet-ebreo/perl/ch-2.pl b/challenge-057/yet-ebreo/perl/ch-2.pl
index 85092a443b..1500740ab4 100644
--- a/challenge-057/yet-ebreo/perl/ch-2.pl
+++ b/challenge-057/yet-ebreo/perl/ch-2.pl
@@ -11,11 +11,15 @@ sub uniq_prefix {
splice @copy, $_, 1;
my $prefix;
+ my $flag = 0;
for my $size (1..length $word) {
$prefix = substr $word, 0, $size;
- last unless grep { /^$prefix/ } @copy
+ unless (grep { /^$prefix/ } @copy ) {
+ $flag = 1;
+ last;
+ }
}
- $prefix;
+ $flag?$prefix:'na';
} 0..$#{$words};
}