Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

what does "$@" mean?

by skyworld_chen (Acolyte)
on Jan 22, 2013 at 01:29 UTC ( #1014528=perlquestion: print w/ replies, xml ) Need Help??
skyworld_chen has asked for the wisdom of the Perl Monks concerning the following question:

Hi

Can anybody tell me what does "$@" mean? thanks very much

Comment on what does "$@" mean?
Re: what does "$@" mean?
by AnomalousMonk (Abbot) on Jan 22, 2013 at 01:34 UTC

    Perl can tell you what it means:
        perldoc -v "$@"
    (You will have to use single- or double- (or no) quotes around  $@ as appropriate to your operating system and shell; the command line above works for me on Win7.)
    See also  $@ and Error Variables in perlvar.

      Hi,

      thanks for your reply. I have checked "perldoc -v '$@' " at my RHE4 with perl v5.8.5, but it shows "No documents found for '$@' ". I then checked the link you provided (Error Variables) to find an explanation as this:

      $@ is set if the string to be eval-ed did not compile (this may happen if open or close were imported with bad prototypes), or if Perl code executed during evaluation die()d. In these cases the value of $@ is the compile error, or the argument to die (which will interpolate $! and $? ).

      Is this mean $@ is only used to contain reasons why perl failed? Thanks.

        The Perl special variable  $@ holds the reason why  eval failed during compilation or execution. See the discussion of eval in perlfunc. Perl failures may have causes that do not originate in eval, and the reasons (actually, error message strings or numeric codes) for these failures are held in other error variables.

        > I have checked "perldoc -v '$@' " at my RHE4 with perl v5.8.5, but it shows "No documents found for '$@' ".

        Neither does 5.10, cause the -v switch was redefined for newer Perl versions!

        But the online doc has variable search, at least for the current versions.

        Cheers Rolf

Re: what does "$@" mean?
by Anonymous Monk on Jan 22, 2013 at 03:12 UTC
Re: what does "$@" mean?
by gryphon (Abbot) on Jan 22, 2013 at 03:41 UTC

    Greetings skyworld_chen,

    I remember it this way: It's the $calar containing typically the text of the @rror from the most recently failed eval block.

    eval { die 'Error string'; } if ($@) { print $@, "\n"; }

    From the command-line, perldoc -f eval to learn more.

Re: what does "$@" mean?
by vinoth.ree (Parson) on Jan 22, 2013 at 04:44 UTC

    The Perl syntax error or routine error message from the last eval, do-FILE, or require command. If set, either the compilation failed, or the die function was executed within the code of the eval.

    Update:

    Perl Special Variables Quick Reference.

Re: what does "$@" mean?
by nithins (Sexton) on Jan 22, 2013 at 04:54 UTC

    go through this "http://perldoc.perl.org/functions/eval.html",you can find the use of eval and also use of "$@" and what it does.

      Thanks for all of your kind replies. I will check these docs.

Re: what does "$@" mean?
by moritz (Cardinal) on Jan 22, 2013 at 05:53 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1014528]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2014-12-21 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls