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 () {
last LINE if /^$/; # exit when done with header
#...
}
What theyre 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++;
}