in reply to Re^4: Auto-generated constructors not finding correct SUPER?
in thread Auto-generated constructors not finding correct SUPER?

Does the whole subroutine need to be eval-ed?
Since "package" has lexical boundaries, yes.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re^5: Auto-generated constructors not finding correct SUPER?

Replies are listed 'Best First'.
Re^6: Auto-generated constructors not finding correct SUPER?
by stvn (Monsignor) on Jan 10, 2005 at 18:37 UTC
    merlyn,

    Thanks for the quick response. I tried this:

    eval "package $pkg; sub new { (shift)->SUPER::new( \%\$fields ); }"
    and got this:
    Variable "$fields" will not stay shared at (eval 32) line 1.
    Although the the 300+ tests passed, and if $fields was somehow lost, they would not have passed. Is this warning something I should worry about? Any idea as to what context $fields is not staying shared within?

    -stvn
Re^6: Auto-generated constructors not finding correct SUPER?
by stvn (Monsignor) on Jan 10, 2005 at 20:52 UTC

    dragonchild figured it out, this code works.

    eval "package $pkg; *new = sub { (shift)->SUPER::new( \%\$fields ); }"
    It avoids the warnings, and all the tests pass. Thanks for the help.

    -stvn