use strict; use warnings; open(FILE, shift) || die($!); while(){ my $hah = $_ =~ s/\#/$&/g; my $ast = $_ =~ s/\*/$&/g; print '*' x 70, "\nLine No. $.\n",'*' x 70, "\n"; $hah = 0 if (!($hah)); $ast = 0 if (!($ast)); print "Number of #'s\t$hah\n"; print "Number of *'s\t$ast\n"; } close(FILE);