Stories
Slash Boxes
Comments
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

use Perl Log In

Log In

[ Create a new account ]

geoff (2013)

geoff
  reversethis-{gro ... om} {ta} {ffoeg}
http://www.modperlcookbook.org/

see http://www.modperlcookbook.org/~geoff/ [modperlcookbook.org] for personal information, links to presentations, GPG key, and so on.

Journal of geoff (2013)

Friday April 02, 2004
10:52 AM

interesting perl problem

[ #18175 ]
so, someone asked me today if there was a way in perl to accomplish something bizarre. I didn't have a quick answer, yet the problem seemed sufficiently interesting that I thought I'd post it here...

say you have script.pl that defines package Foo. now, for complex legacy reasons, your stuck with this and need to call script.pl both from the command-line as well as

require "script.pl";
Foo->import;

how do you create a chunk of code that only executes from the command-line and not when script.pl is loaded or imported?

I might be missing something obvious, but the only thing I could come up with was requiring some random command-line argument and checking @ARGV. apparently that's not an option.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.