[ale] Shell script
Fletch
fletch at phydeaux.org
Wed Sep 27 22:19:31 EDT 2000
>>>>> "Wandered" == Wandered Inn <esoteric at atlnet.com> writes:
Wandered> How about perl? Assuming you have one entry per line:
Wandered> cat fileonumbers | perl -ne 'BEGIN { my $total=0;}
Wandered> {$total +=$_;}END {print $total;}'
*tweet*
Useless use of cat. Five yards, repeat the down.
And that `BEGIN { my $total = 0 }' is doing nothing. The
lexical my that you declare there goes out of scope as soon as the
block is done. You're actually using the global $::total, which
starts out undefined (which conveniently is treated numerically a just
zero).
Not to mention all the gratuitous use of whitespace. :)
perl -lne '$t+=$_;END{print$t}' fileonumbers
Can't get much closer to TECO than that, at least not without
some more punctuation chars.
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org | Vincent, you should cease askin' \ o.O'
678 443-6239(w) | scary questions." -- Jules =(___)=
| U
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list