RosettaCodeData/Task/Longest-string-challenge/Perl-6/longest-string-challenge.pl6

14 lines
362 B
Raku
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
my $l = ''; # Sample longest string seen.
my $a = ''; # Accumulator to save longest strings.
2013-06-05 21:47:54 +00:00
while get() -> $s {
2013-04-10 22:43:41 -07:00
my $n = "$s\n";
if $n.substr($l.chars) { # Is new string longer?
$a = $l = $n; # Reset accumulator.
}
elsif !$l.substr($n.chars) { # Same length?
$a ~= $n; # Accumulate it.
}
}
print $a;