Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^5: Sub hash param by reference

by Athanasius (Archbishop)
on Jul 10, 2016 at 08:44 UTC ( [id://1167516]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Sub hash param by reference
in thread Sub hash param by reference

Hello hankcoder,

I'm not quite understand what is $_[0]

The special variable @_1 is documented as follows:

Within a subroutine the array @_ contains the parameters passed to that subroutine. Inside a subroutine, @_ is the default array for the array operators pop and shift.

Now, in Perl2 you access the individual elements of array @my_array as $my_array[0], $my_array[1], $my_array[2], .... (Note that the first element has index zero.) In the same way, the array @_ (which is named “ _ ”) has elements $_[0], $_[1], $_[2], .... So $_[0] is the first parameter passed to the subroutine.

1You can also call it @ARG if you use English; — see perlvar#General-Variables.
2That is, Perl 5 and earlier. I believe Perl 6 uses a different syntax.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^6: Sub hash param by reference
by hankcoder (Scribe) on Jul 10, 2016 at 12:46 UTC

    Thanks Athanasius for the clear explanation.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1167516]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-03-29 08:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found