Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Dual personality: Module and script

by fergal (Chaplain)
on Aug 03, 2004 at 15:23 UTC ( [id://379696]=note: print w/replies, xml ) Need Help??


in reply to Dual personality: Module and script

Here's a solution that works with require and use. Assuming it's saved in mod.pm
print "I'm a ".($INC{"mod.pm"} ? "module" : "script")."\n";
output is
fergal@linux:~> perl mod.pm
I'm a script
fergal@linux:~ perl -e 'require mod'
I'm a module

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 02:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found