(note the use of foreach, or and $! ...)@letter = qw/a b c w x y/; foreach $x (@letter) { $m = 0; open(DATA,"data.txt") or die "couldn't open data\n$!"; while (<DATA>) { $m += ($_ =~ s/$x/$x/g); } close(DATA); print "count $x = $m\n"; }
| Regards... | Stefan |
In reply to Re: A another tr/// statement question..
by stefan k
in thread tr/// statement
by supernewbie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |