I am stuck on chapter 4 exercise 4 page 78 of Learning Perl 6th Edition. I copied the code example for the problem from page 301. I am using Perl version 5.10.1 on Ubuntu 11.04. I get errors that I cannot figure out could someone please help? I will list the code and the error message below.
#!/usr/bin/perl -w
use strict;
greet( 'Fred' );
greet( 'Barney' );
sub greet {
state $last_person;
my $name = shift;
print "Hi $name! ";
if( defined $last_person ) {
print "$last_person is also here!\n";
}
else {
print "You are the first one here!\n";
}
$last_person = $name;
}
Global symbol "$last_person" requires explicit package name at ./ex4-4 line 8.
Global symbol "$last_person" requires explicit package name at ./ex4-4 line 14.
Global symbol "$last_person" requires explicit package name at ./ex4-4 line 15.
Global symbol "$last_person" requires explicit package name at ./ex4-4 line 20.
Execution of ./ex4-4 aborted due to compilation errors.
From the manual: