package Thing;
use Moo;
has topdir => (
is => 'rw',
required => 1,
);
use strict;
use warnings;
use Function::Parameters;
# Methods
method loop() {
while (1) {
my $val = rand(100);
if ($val > 80) {
# Do nothing if value is over 80
nnext; # This line has the actual error
}
($val < 20) and return $val;
}
}
method getcwd() {
my $cwd = $self->topdir;
return $cwd;
}
####
"my" variable $cwd masks earlier declaration in same statement at Thing.pm line 31.
##
##
method getcwd() {
return $self->topdir;
}
##
##
perl -c Thing.pm
Bareword "nnext" not allowed while "strict subs" in use at Thing.pm line 21.
syntax error at Thing.pm line 29, near ") {"
Global symbol "$self" requires explicit package name at Thing.pm line 30.
Thing.pm had compilation errors.