lee,
You have a post statement if and then a code block. You can only use one of
two forms:
print "test" if $color eq "blue"; #no parenthesis required
if($color eq "blue"){print "test";}
As far as last, http://perldoc.perl.org/functions/last.html
The example given:
LINE: while (<STDIN>) {
last LINE if /^$/; # exit when done with header
#...
}
What they're saying here is that it breaks out of a loop. Its not like a
return where it breaks out of a subroutine, it just continues beyond the
loop.
I think this fixes your program:
use strict;
use warnings;
use autodie;
my $counter = 0;
while($counter < 8) {
if($counter > 2) {
print "if: " . $counter . "\n";
last;
}
else {
print "else: " . $counter . "\n";
}
$counter++;
}
Cheers,
James
On Mon, Jun 17, 2013 at 6:56 AM, lee <[email protected]> wrote:
>
> Hi,
>
> trying to figure out what `last' actually does, I wrote this test
> script: