in reply to next in while loop not honored

If you are using explicit ranges like that then use for loops instead of while loops to make it clear that a range is being dealt with and what the range is. Consider:

#!/usr/bin/perl use strict; use warnings; my $maxline = 5; my $start = 2; my $fileName = "testlog"; open my $info, '<', $fileName or die "Could not open '$fileName': $!"; <$info> // die "Log file '$fileName' too short\n" for 1 .. $start - 1; for ($start .. $maxline) { my $line = <$info> // die "Log file '$fileName' too short\n"; print $line; }

The <$info> // die ... stuff dies on end of file.

Perl is the programming world's equivalent of English

Replies are listed 'Best First'.
Re^2: next in while loop not honored
by mitchreward (Acolyte) on Nov 06, 2014 at 16:23 UTC
    thanks to all of you guys