http://www.perlmonks.org?node_id=11666

Vote on this poll

$_
[bar] 96/61%
$@
[bar] 9/6%
$<
[bar] 3/2%
$/
[bar] 9/6%
$!
[bar] 17/11%
Where's $*
[bar] 9/6%
Other
[bar] 14/9%
157 total votes
Replies are listed 'Best First'.
"Dude!" Variable
by neshura (Chaplain) on May 15, 2000 at 20:34 UTC
    Why is $_ by far my favorite? Hmmm...there's a car commercial out there, I can't remember which car company. Anyway, it's touting the amazing suspension by having four coffee-swilling Xers driving around. They just keep saying "Dude!" over and over again in various intonations. The driver is heading for railroad tracks, and the exclamations of "Dude!" get increasingly agitated (anticipating hot coffee in lap).

    It ends predictably of course, but the point is that we know what they are saying beyond just "Dude!". Well, I do, anyway.
    Point: The conversational form of "Dude!" and the perl variable $_ are disturbingly analogous...

    e-mail neshura

      Dude.

      Duuuuuuddddeeee.

      Dude?

      Dude.

        Homes

        Buddy

        Heh heh heh, that's a pretty good cartoon short.

        --
        perl -pe "s/\b;([st])/'\1/mg"

      Dude, I totally know what you're saying... dude!

      Sorry, I couldn't resist!
      Dude
        Personally, I enjoy the variant form of Dude - the "intentional typo, just because I like it that way" Dued!
RE: Favorite Symbol Variable
by guice (Scribe) on May 15, 2000 at 20:09 UTC
    You have $/ but where's $\? Playing with mutiple platforms like I do, $\ proved to be very useful. It's a very usefull playing with files. Another one of my favorites is $| and $" ... You can do some nice prints of arrays when you play with $" :).
    Just my thought on things ...

    -- philip
    We put the 'K' in kwality!

RE: Favorite Symbol Variable
by snowcrash (Friar) on May 16, 2000 at 14:49 UTC
    my absolute fav is $^W, better written as ${chr(24)} :)
    it's default value beats the others, too.

    cheers
    sc
      That is definately a good one, but only when $^W==1
RE: Favorite Symbol Variable
by PipTigger (Hermit) on May 16, 2000 at 05:43 UTC
    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! =)
      $@ - 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.
      $@ - 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: Favorite Symbol Variable
by radixzer0 (Beadle) on May 17, 2000 at 00:14 UTC
    $_ RULZ
    Seriously, though, how can you not like a variable that is so useful that 95% of the time you dont even need to reference it explicitly.

    Or, on the other hand, how can you not pick $_ when you (intentionally or not) use it more than any other?

    Be one with the $_.....
    -r0

      Thing is, you barely ever have to type $_ - despite it being implicitly used millions of times each day.
      Well .. I use it so often, I don't even think of it as there. It's became, well ... default. It's the most useful variable in Perl, but cause I use it so much, I don't see it as a 'kewl' variable. You can't 'do' much with it. Where $\ and $" actually let you play with how things are displayed. Just like CDs where kewl and most useful for ditital media until it's so popular, it's not longer 'kewl'.
RE: Favorite Symbol Variable
by Adam (Vicar) on May 16, 2000 at 18:44 UTC
    I'm partial to $[ but $_ takes a close second. j/k

View List Of Past Polls