http://www.perlmonks.org?node_id=961158


in reply to Problem in command line arguements

Is there any variable which stores the parameter passed before the actual script name

No. That information is not available anywhere within your perl script.

When you type the command line sudo perl myscript.pl the following steps occur:

  1. The command shell starts the sudo program passing 'sudo' as it first argument, 'perl' as the second, 'myscript.pl' as the third.
  2. The sudo program then starts perl passing 'perl' as it first argument and 'myscript.pl' as the second.

Perl is never aware of the original first argument.

However, there are a couple of approaches you might use to discover it:


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: Problem in command line arguements
by firearm12 (Novice) on Mar 24, 2012 at 15:36 UTC
    Thanks very much for your response.