[ale] Shell script
Wandered Inn
esoteric at atlnet.com
Thu Sep 28 09:03:38 EDT 2000
Thanks for the lesson, I did learn from it. Then again, it was a quick
command line one liner. Not a lot of thought put into it, as you have
certainly demonstrated. I don't do a lot of perl on the command line.
It does work though. :)
Fletch wrote:
>
> >>>>> "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.
--
Until later: Geoffrey esoteric at denali.atlnet.com
"Great spirits have always found violent opposition from mediocre minds.
The
latter cannot understand it when a man does not thoughtlessly submit to
hereditary prejudices but honestly and courageously uses his
intelligence."
- Albert Einstein
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list