Perl Monk, Perl Meditation | |
PerlMonks |
Golf: Length of longest line in a fileby toolic (Bishop) |
on Jul 02, 2010 at 16:01 UTC ( [id://847747]=perlmeditation: print w/replies, xml ) | Need Help?? |
I needed to determine the length of the longest line in a file today.
After overcoming the surprise that I can't recall ever needing to do such a
thing before, I banged out this Perl script:
Running the code on the following file would print 7. The trailing newline is included in the length of a line.
Reflecting on the code over lunch, it occurred to me that that was way too many characters. Here is my 38:
Please show me how to slim this down.
Back to
Meditations
|
|