Quote:
Originally Posted by J65nko
...a Perl script to count the number of comma's...
|
Consider the following
(assuming comma are not found in the data...):
Code:
#!/bin/env perl
use strict;
use warnings;
# array of test strings
my @a = (',', ',,', ',,,');
my $max = 0;
foreach my $line (@a) {
my @matches = ($line =~ /(\,)/g);
$max = @matches if @matches > $max;
}
print "max #occurrences = $max\n";
TIMTOWTDI.