amittleider has asked for the wisdom of the Perl Monks concerning the following question:
Thanks for any/all comments! AJ#sub countChar() { # open (DAT, "@ARGV"); # print "Character count\n"; # while ($line = <DAT>){ # my @line_words = split (//, $line); # foreach my $char (@line_char){ # if ($charCount{$char}){ # $charCount{$char}++; # }else { # $charCount{$char}=1; # } # } # } # foreach $char (keys %charCount) { # print "$char => $charCount{$char}\n"; # } # close(DAT, "@ARGV"); #} #foreach $char (keys %charCount) { # print "$char => $charCount{$char}\n"; #} sub countChar() { open (DAT, "@ARGV"); print "Character count\n"; while ($line = <DAT>){ do (@word = split (/\W/, $line)); foreach $word (keys %charCount){ do (@letter = split (/\w+/, $word); $letter = (keys %charcount)} if ($charCount){$char}){ $charCount{$char}++; }else { $charCount{$char}=1; } foreach $char (keys %charCount) { print "$char => $charCount{$char}\n"; } close(DAT, "@ARGV"); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash to count characters
by jwkrahn (Abbot) on Aug 12, 2010 at 03:51 UTC | |
|
Re: Hash to count characters
by nvivek (Vicar) on Aug 12, 2010 at 03:27 UTC | |
by amittleider (Initiate) on Aug 12, 2010 at 05:46 UTC | |
by roboticus (Chancellor) on Aug 12, 2010 at 11:54 UTC | |
|
Re: Hash to count characters
by dasgar (Priest) on Aug 12, 2010 at 05:48 UTC | |
|
Re: Hash to count characters
by JavaFan (Canon) on Aug 12, 2010 at 09:05 UTC | |
|
Re: Hash to count characters
by FunkyMonk (Bishop) on Aug 12, 2010 at 09:22 UTC | |
|
Re: Hash to count characters
by roboticus (Chancellor) on Aug 12, 2010 at 12:26 UTC | |
by Anonymous Monk on Aug 12, 2010 at 20:11 UTC |