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

So, given that, how would I make the following code work in package Right? My problem is that I need to create constructors that are closures ...
package Wrong; sub builder { my $pkg = shift; my @args = ( # A bunch of random stuff here, including objects ); { no strict 'refs'; *{ $pkg . '::new' } = sub { (shift)->SUPER::new( @args ); }; } }

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
•Re^3: Auto-generated constructors not finding correct SUPER?
by merlyn (Sage) on Jan 10, 2005 at 14:26 UTC
      merlyn

      I am confused by your answer, when I try this:

      { eval "package $pkg;"; no strict 'refs'; *{$pkg . '::new'} = sub { (shift)->SUPER::new(%{$fields}) }; }
      I get the same error as before. And when I try this:
      { no strict 'refs'; *{$pkg . '::new'} = sub { eval "package $pkg;"; (shift)->SUPER::new(%{$fields}) }; }
      I get the same error as well. It would seem to me that SUPER is determined at compile time, is that true?

      Does the whole subroutine need to be eval-ed?

      -stvn