Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday June 12, 2008
09:33 AM

Guess Why This Works

[ #36671 ]

After a long, painful session of dodging segfaults, I finally discovered the answer to my problem:

foreach my $method (@methods) {
    no strict 'refs';
    *$method = sub { shift->$method(@_) };
}

All tests pass and there are no recursion issues. Also, it turns out to be documented core behavior.

Just try and guess why I need this.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Somewhere, somehow, something is doing $object->foo::bar(@stuff) and you're needing to catch these calls in package foo and tell it that no, you really wanted to make those method calls on $object, not on package foo.

    That situation would avoid all recursion problems with that code and is documented in the core. But I would need to know more about your code to guess why it might do something silly like call the method foo::bar.

    However I suspect that you have lots of things that you want dispatched to pac
    • Or, the code is "print($object, ...)" (replace "print" with any other core or imported symbol) and Ovid wants the $object to control the behavior. The alternative is a solution like UNIVERSAL::isa.