Thread Wörter im Array zählen (4 answers)
Opened by wiederlader at 2008-02-19 15:34

murphy
 2008-02-19 15:42
#106103 #106103
User since
2004-07-19
1776 Artikel
HausmeisterIn
[Homepage]
user image
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.

View full thread Wörter im Array zählen