Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Alias vs Reference

by eyepopslikeamosquito (Canon)
on Jun 16, 2012 at 07:46 UTC ( #976552=note: print w/ replies, xml ) Need Help??


in reply to Alias vs Reference

Some places aliases are used:

  • $_ in foreach, map and grep and named loop variables in foreach
  • $a and $b in a sort block
  • $a and $b in List::Util's reduce function and List::MoreUtils's pairwise function
  • Each element of @_ for the actual arguments in a subroutine call
  • By packages importing symbols
  • By an our declaration, which creates a lexically scoped alias
  • You can explicitly create an alias via typeglobs

See also "alias" in perlglossary and Item 118 "Access the symbol table with typeglobs" in Effective Perl Programming.

Update: added named loop variables in foreach. Thanks Jenda.


Comment on Re: Alias vs Reference
Select or Download Code
Re^2: Alias vs Reference
by Jenda (Abbot) on Jun 16, 2012 at 09:53 UTC

    Not just $_ in foreach. Named loop variables in foreach are also aliases.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-09-17 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (56 votes), past polls