in reply to Re^2: Code from perlboot not working as expected
in thread Code from perlboot not working as expected

$class is a reference to the object and I believe that's what you get when you print out a reference. Just dereference it (note the double $): print "a $$class goes ", $class->sound, "!\n"; Kevin Sigl
  • Comment on Re^3: Code from perlboot not working as expected

Replies are listed 'Best First'.
Re^4: Code from perlboot not working as expected
by kennethk (Abbot) on May 17, 2010 at 15:00 UTC
    Dereferencing will get you the value contained in the scalar reference, but the spec expects the package name. The code

    print "a $$class goes ", $class->sound, "!\n";

    will yield the output

    a Mr. Ed goes neigh!

    not the expected

    a Horse goes neigh!

    It will also fail outright if the code is invoked statically, with the error under strict:

    Can't use string ("Horse") as a SCALAR ref while "strict refs" in use