Take the 2-minute tour ×  The question is not how to tell in a
oneliner. If you're writing the code in a one-liner, you know
you are. But how does a module, included by -MMy::Module::Name
know that it all started from a oneliner.  This is mine. It's
non-portable though and relies on UNIX standard commands
(although, it can be made portable more or less.)  my
$process_info = `ps $$ | tail -1`; my $is_oneliner       =
$process_info =~
m/perl.*?\s+-[^\P{IsLower}e]*e[^\P{IsLower}e]*\s+/m  And if you
have a snazzier regex, feel free to improve upon mine.  A couple
of people have asked why I would want to do this. brian
correctly guessed that I wanted to change export behavior based
on whether it's a script, which we can assume has had some
amount of design, or whether it's a oneliner where the user is
trying to do as much as possible in a single command line.  This
sounds bad, because there's this credo that exporters should
respect other packages--sometimes known as "@EXPORT is EVIL!"
But it seems to me that it's