in reply to Re: count the occurrences of particular word in a file and extract number in ()
in thread count the occurrences of particular word in a file and extract number in ()
For #2, simpler code:use strict; my $count = 0; while( <DATA> ) { print; ++$count while m[the]ig; } print "'the' appeared $count times in 'theFile'\n"; __DATA__ THis is the dawning of the age of Aquarius. Good morning Starshine, the earth says hello. The end.
my ($extracted_value) = $extract =~/^\( (\d.+) \)$/; # Will be undef if nothing found.
Syntactic sugar causes cancer of the semicolon. --Alan Perlis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: count the occurrences of particular word in a file and extract number in ()
by BrowserUk (Patriarch) on Mar 20, 2011 at 05:57 UTC |