Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Getting module to call importer's function

by BrowserUk (Patriarch)
on Sep 22, 2004 at 21:26 UTC ( [id://393054]=note: print w/replies, xml ) Need Help??


in reply to Getting module to call importer's function

Why not just pass a reference to the callback sub?

package M; use strict; require Exporter; our @ISA = qw[ Exporter ]; our @EXPORT = qw[ x ]; sub x{ my( $sub ) = @_; &$sub; } 1;
#! perl -slw use strict; use M; sub _x{ print __PACKAGE__ . "_x() called" } x( \&_x ); __END__ P:\test>393046 main_x() called

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^2: Getting module to call importer's function
by jredburn (Sexton) on Sep 22, 2004 at 21:31 UTC
    The problem is that I'm calling x from an external library so I don't have that freedom. You guys got me on the right track though, thanks much!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://393054]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found