>> #!/usr/bin/perl -w
>>
>> while (<STDIN>) {
>> $i++;
>> next if $i < 3;
>> last if $i > 6;
>>
>> $total += (split)[1];
>> }
>> print "$total\n";
>
>Yuck! Perl - the Swiss Army chainsaw of Unix tools. =8^)
>
>Too verbose for the simple stuff, not quite enough for the real hard stuff.
Nah, he wasn't trying:
#!/usr/bin/perl -w
while (<>) {
$total += (split)[1] if ($. >= 3 and $. <= 6);
}
print "$total\n";
Not much different from awk, plus this will work if the file is specified
on the command, doesn't have to be redirected to stdin.
Might have an off-by-one error, etc., don't pick nits, I just want to
convey the idea Perl doesn't have to be verbose, or cryptic either.
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text