On Jan 28, John McKown said:
>On Wed, 28 Jan 2004, Jeff 'japhy' Pinyan wrote:
>
>> while (<FILE>) {
>> if (10 .. 20) {
>> print; # displays lines 10 through 20
>> }
>> }
>
>Wouldn't the following be slightly faster?
>
> while (<FILE>) {
> next if $. < $start;
> last if $. > $end;
> ... processing ...
> }
>
>the above example "aborts" reading the file once the last line has been
>read.
Certainly, IF you only one to process one range.
while (<FILE>) {
print "small " if 1 .. 10;
print "medium " if 6 .. 15;
print "big " if 11 .. 20;
print "\n";
}
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>