mitchreward has asked for the wisdom of the Perl Monks concerning the following question:
Hi, fellow monks
I have a logfile composed of 7 lines;
I'd like to start processing at line X and stop at line N;
This next exit the while and I cant get why, could you help ?
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $maxline = 5; open my $info, "testlog" or die "Could not open $!"; my $start = 2; my $count = 0; while( my $line = <$info>) { next if $count < $start; print $line; last if ++$count == $maxline; print "$count \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: next in while loop not honored
by MidLifeXis (Monsignor) on Nov 05, 2014 at 16:20 UTC | |
|
Re: next in while loop not honored
by choroba (Cardinal) on Nov 05, 2014 at 16:21 UTC | |
|
Re: next in while loop not honored
by Eily (Monsignor) on Nov 05, 2014 at 16:22 UTC | |
|
Re: next in while loop not honored
by GrandFather (Saint) on Nov 05, 2014 at 20:21 UTC | |
by mitchreward (Acolyte) on Nov 06, 2014 at 16:23 UTC | |
|
Re: next in while loop not honored
by Laurent_R (Canon) on Nov 05, 2014 at 20:14 UTC | |
by GrandFather (Saint) on Nov 05, 2014 at 20:27 UTC | |
by Laurent_R (Canon) on Nov 05, 2014 at 22:21 UTC |