davies has asked for the wisdom of the Perl Monks concerning the following question:
I have added the first and last lines. This gives an erroruse strict; { package Animal; sub speak { my $class = shift; print "a $class goes ", $class->sound, "!\n"; } } { package Horse; our @ISA = qw(Animal); sub sound { "neigh" } } my $name = "Mr. Ed"; my $horse = \$name; bless $horse, Horse; $horse->speak;
Taking out Strict gives a different error: a Horse=SCALAR(0x1829afc) goes neigh! While this isn't a syntax error, it's not what I was expecting from reading the tutorial. Advice on what I'm doing wrong would be greatly appreciated.Bareword "Horse" not allowed while "strict subs" in use at C:\Data\per +lbootqry.pl line 17. Execution of C:\Data\perlbootqry.pl aborted due to compilation errors.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Code from perlboot not working as expected
by kennethk (Abbot) on May 17, 2010 at 13:19 UTC | |
by davies (Monsignor) on May 17, 2010 at 14:39 UTC | |
by kennethk (Abbot) on May 17, 2010 at 14:49 UTC | |
by davies (Monsignor) on May 17, 2010 at 15:10 UTC | |
by Anonymous Monk on May 17, 2010 at 14:51 UTC | |
by kennethk (Abbot) on May 17, 2010 at 15:00 UTC | |
|
Re: Code from perlboot not working as expected
by JavaFan (Canon) on May 17, 2010 at 13:17 UTC | |
by davies (Monsignor) on May 17, 2010 at 14:37 UTC | |
by JavaFan (Canon) on May 17, 2010 at 15:23 UTC |