Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Was my module used or required?

by Anonymous Monk
on Dec 06, 2002 at 23:29 UTC ( [id://218184]=note: print w/replies, xml ) Need Help??


in reply to Was my module used or required?

Some test code expanding on Jenda's suggestion, partially to satisfy my own curiosity. Interesting problem, hope this is of some help - its rough.
A runtime flag in caller() lets your module evaluate at what stage it is being compiled...
package amIBeingUsed; # in amIBeingUsed.pm if(defined( ${ caller()."::RUNTIME_OK" } )) { # the flag is set print "what took you so long to call me?"; } else { # still compiling print "eurgh, i feel so cheap!"; } sub import { print " slap!!!\n"; } 1;
...meanwhile, at the Bat Cave ...
use strict; my $module = "amIBeingUsed"; our $RUNTIME_OK = 1; # possible scenarios use amIBeingUsed; # "eurgh, i feel so cheap! slap!!!" eval "use $module"; # "what took you so long to call me? slap!!!" require amIBeingUsed; # "what took you so long to call me?" eval "require $module"; # "what took you so long to call me?"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found