Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use Data::Dumper;
- my %char_counter;
- # how to handle no args?
- open(FIN, '<', $ARGV[0]) or die("Can not open file \"$ARGV[0]\"");
- while (<FIN>)
- {
- my $char;
- foreach $char (split('', $_))
- {
- if ($char =~ m/[[:print:]]/g)
- {
- $char_counter{$char} += 1;
- } else
- {
- $char_counter{ord($char)} += 1;
- }
- } # end foreach
- }
- close(FIN);
- # why we have to put "\" before "%"?
- print Dumper(\%char_counter);
- exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement