Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: reaching into a perl script from a package

by kwaping (Priest)
on Oct 02, 2006 at 19:46 UTC ( [id://575936]=note: print w/replies, xml ) Need Help??


in reply to Re^2: reaching into a perl script from a package
in thread reaching into a perl script from a package

Actually, you can require them. However, if there is any code inside that isn't wrapped in a sub, it will execute when the file is required. Example:
#!/usr/bin/perl ### the file doing the requiring use strict; use warnings; use lib '/path/to/lib'; require('tmp.pl'); asdf();
---
#!/usr/bin/perl ### the file being required use strict; use warnings; print "hi there\n"; sub asdf { print "well howdy"; } 1;
---
### the output hi there well howdy

---
It's all fine and dandy until someone has to look at the code.

Log In?
Username:
Password:

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

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

    No recent polls found