Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How come @_ gets changed here?

by pritesh_ugrankar (Monk)
on Jun 10, 2017 at 22:35 UTC ( [id://1192494]=note: print w/replies, xml ) Need Help??


in reply to How come @_ gets changed here?

Respected Monks,

Thank you for taking time to reply.

I used & at the beginning of a function because, as per Learning Perl book, I am to use an & before calling the function, else, I might accidentally end up calling a perl built-in. In fact there is a link given in the book https://www.learning-perl.com/2013/05/why-we-teach-the-subroutine-ampersand/ which if I understood right, is stating it's better to use & when one is not sure.

But from the posts here, I reckon it's not encouraged. So I'm not sure if I should or shouldn't use the &. I will later try to test on other version(s) of Perl and see how it goes.

Replies are listed 'Best First'.
Re^2: How come @_ gets changed here?
by Anonymous Monk on Jun 10, 2017 at 23:30 UTC
    In that article, brian d foy is saying that using & sometimes avoids trouble for people who are very new to Perl. What the rest of us are saying is that using & causes more trouble for intermediate-level Perl programmers. Decide for yourself which category you are in, but remember that & is old-perl.

    Mr foy suggests that it is ok to type "&foo;", but never do that, because it actually passes @_ to foo. Always put the parens. "foo();" or "&foo();", but not "&foo;" unless you really mean it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-26 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found