Slash Boxes
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.
More | Login | Reply
Loading... please wait.
  • If at the top level, you check caller(), you'll find it is false if the script is run as a standalone program, and true if it's loaded as a library.

    Thus, do this at the top level:

    unless(caller) {
       # former top level
       print "Run as a script\n";
    } else {
       # you may drop this if you don't need it
       print "Initializing as a library file\n";
    It'll work now.
    • Thank you. Sounds like this advice was either present in the slides I read, and I missed it (it was middle of the night, up late hacking for work :) ), or else the presenter missed it or only mentioned it orally without including it in the slides.

      J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers