umasuresh has asked for the wisdom of the Perl Monks concerning the following question:
Here is a reference to what I tried so far: Update: http://www.codecodex.com/wiki/Count_the_number_of_occurrences_of_a_specific_character_in_a_stringuse strict; { local $/ = '\n'; while (<DATA>) { my $count = () = $_ =~ /XY[0-9]+/g; print "$count\n"; } } __DATA__ 22601571,XY12273,XY18561,XY19079,XY20765,XY18924 148986884,XY18644,XY18756,XY17986,XY19453,XY19121
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: count the number of occurrences of a pattern in a file
by almut (Canon) on Apr 20, 2010 at 16:53 UTC | |
by johngg (Canon) on Apr 20, 2010 at 22:35 UTC | |
|
Re: count the number of occurrences of a pattern in a file
by kennethk (Abbot) on Apr 20, 2010 at 16:56 UTC | |
|
Re: count the number of occurrences of a pattern in a file
by Anonymous Monk on Apr 20, 2010 at 16:49 UTC |