Thread Wörter im Array zählen
(4 answers)
Opened by wiederlader at 2008-02-19 15:34
Ich würde es so versuchen:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 use 5.010; use strict; use warnings; my @names = qw/Markus Fritz Otto/; my @candidates = <>; chomp @candidates; foreach my $name (@names) { my $count = scalar grep /\Q$name\E/, @candidates; say "'$name' encountered $count times"; } When C++ is your hammer, every problem looks like your thumb.
|