Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Alias vs Reference

by eyepopslikeamosquito (Bishop)
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-06-15 02:53 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (66 votes). Check out past polls.