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.