|
|
| Think about Loose Coupling | |
| PerlMonks |
Re: Golf: Improve this guy's fail . . . please!by moritz (Cardinal) |
| on Jun 30, 2009 at 22:06 UTC ( #776196=note: print w/ replies, xml ) | Need Help?? |
|
This looks embarrassingly similar to my first Perl scripts, except that I never called subroutines with a leading & because I had the luck to learn Perl 5 from the start ;-). It's a typical case of not knowing about autovivification: instead of assigning 0 to every possible hash key, and later sort out those which remained 0, you can simply leave out both steps altogether. It is also typical in confusing ASCII with an 8-bit encoding. A non-golfed version:
It doesn't prompt for a filename, instead it either expects a file name on the command line, or reads from STDIN - in good old unix tradition.
In Section
Meditations
|
|
||||||||||||||||||||||||||||