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

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.
  • Why not just sub{}?
      $method = sub { $object->$method };

    -Dom

    • Now that I've had some coffee, I can't really remember anymore what I already got and what I was considering on using... *must .. race .. home .. quickly*
      • I sympathise. I've often wondered deeply on the following day about code that got written after midnight...

        -Dom

  • $method = \&Object::method;

    Hardcoding considered suboptimal (for a range of reasons). You want this:

    $method = $object->can( 'method' );

    You have to remember to pass a reference to $object in either case, though. No getting around that in Perl.

    Therefore you would normally use a closure as per Dominic’s suggestion.