http://qs1969.pair.com?node_id=11806


in reply to Favorite Symbol Variable

The first choice ($_) is the only one I've ever used before (well that's not including "other" which I've certainly used before =) ). Would anyone care to give a terse summary of the usefulness and appropriate contexts for each of the others? For MonksInTraining, it would be nicely instructional. Thanks muchly in advance. TTFN & Shalom.

-PipTigger
p.s. Come to think of it, I like $# better than $_ but it's more like $#xxxx and you don't really get $_xxxx so it probably doesn't belong. =) I'm a dork.
p.p.s. So as not to be a hypocrite, for those who haven't seen $#xxxx before, it is the scalar value associated with the last indexable value in an array (er list... whichever is the politically correct name for it these days). You can quickly modify the size of an array/list by assigning a new value to this scalar (ie. To cut the array junklist in half rounded up do: $#junklist /= 2; ). Keep in mind that this value is always one less than the scalar context of the array name itself (ie. @junklist). This is true even in an empty list when the scalar context for @junklist == 0 && $#junklist == -1. Happy Hacking! =)

Replies are listed 'Best First'.
RE: RE: Favorite Symbol Variable
by Anonymous Monk on May 17, 2000 at 02:36 UTC
    $@ - how your most recent eval() screwed up. $< - the real uid of your process. $/ - the input line separator; useful for slurping in files. $! - how anything else in your program but eval() most recently screwed up. $* - let Perl assume that strings are single-line for regex matching.
RE: RE: Favorite Symbol Variable
by Anonymous Monk on May 17, 2000 at 03:51 UTC
    $@ - how your most recent eval() screwed up. $< - the real uid of your process. $/ - the input line separator; useful for slurping in files. $! - how anything else in your program but eval() most recently screwed up. $* - let Perl assume that strings are single-line for regex matching.