Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: why the value of count will be change?

by LanX (Saint)
on May 08, 2018 at 23:51 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-24 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found