Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: why the value of count will be change?

by LanX (Sage)
on May 08, 2018 at 23:51 UTC ( #1214241=note: print w/replies, xml ) Need Help??

in reply to why the value of count will be change?

Because Perl does call by reference

The elements in @_ are aliases, you should copy them first.

From perlglossary

  • alias
A nickname for something, which behaves in all ways as though you’d used the original name instead of the nickname. Temporary aliases are implicitly created in the loop variable for foreach loops, in the $_ variable for map or grep operators, in $a and $b during sort’s comparison function, and in each element of @_ for the actual arguments of a subroutine call. Permanent aliases are explicitly created in packages by importingsymbols or by assignment to typeglobs. Lexically scoped aliases for package variables are explicitly created by the our declaration.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

PS: And for god's sake, please use indentation!

  • Comment on Re: why the value of count will be change?

Replies are listed 'Best First'.
Re^2: why the value of count will be change?
by yueli711 (Sexton) on May 09, 2018 at 00:06 UTC

    Thank you so much! My question is why the value of count is just the number of the data in @? Thank you in advance!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2023-01-29 22:58 GMT
Find Nodes?
    Voting Booth?

    No recent polls found