princepawn has asked for the wisdom of the Perl Monks concerning the following question:

I checked perlvar on this, but would rather be 100% certain that what I am saying is right. Some one in my office was wondering if there were a single global (actually package local to package main) variable that contained "$0 @ARGV"

But checking perlvar yields no such thing.

Replies are listed 'Best First'.
Re: is there are global perl variable with
by japhy (Canon) on Aug 13, 2001 at 22:23 UTC
    No such thing. You produced it yourself, just now.
    # create such a thing BEGIN { ${^CMDLINE} = "$0 @ARGV" }
    But that's not entirely accurate. You should add quotes around each element in @ARGV, and quotemeta() them.
    BEGIN { ${^CMDLINE} = join ' ', $0, map "'\Q$_\E'", @ARGV }
    This variable will then be as global as @ARGV and $0.

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Re: is there are global perl variable with
by trantor (Chaplain) on Aug 13, 2001 at 22:22 UTC

    Is it "$0 @ARGV" (interpolated string) or ($0, @ARGV) (list of program name and its arguments)?

    In any case, there is no such variable. Should it be necessary, it couldn't be simpler to bring it to life in your programs.

    Anyway, avoiding to create new globals is almost always a good idea.

    -- TMTOWTDI