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

Re: Alias vs Reference

by eyepopslikeamosquito (Chancellor)
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.

Replies are listed 'Best First'.
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.

    Enoch was right!
    Enjoy the last years of Rome.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://976552]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2018-08-16 05:53 GMT
Find Nodes?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:

    Results (167 votes). Check out past polls.