Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

what is...

by Anonymous Monk
on Mar 09, 2002 at 10:51 UTC ( [id://150534]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

i'm a newbie so...
what is $foo?
what is $bar?
what is $foobar?

thanks.

"asking stupid questions is better than staying stupid forever".

Replies are listed 'Best First'.
Re: what is...
by Amoe (Friar) on Mar 09, 2002 at 13:01 UTC

    Ah, the whimsy of programmers. Various combinations of "foo", "bar", "baz" and other strings involving seemingly random chracters have been used as arbitrary variable identifiers when the programmer can't be bothered to think of one since time began. The technical term is "metasyntactic variables". They're not special to Perl. :)

    For more info, see metasyntactic variables at FOLDOC.



    --
    my one true love
Re: what is...
by cjf (Parson) on Mar 09, 2002 at 10:54 UTC
    Why they're all variables of course :)

    More specifically, they're commonly used as example variables and, as far as I know, don't mean anything specific.

Re: what is...
by derby (Abbot) on Mar 09, 2002 at 13:54 UTC
    AM, As other have pointed out, they're just metavariables (that is, temp names when you really don't know or care what the real variable name is). Others above have pointed out great links but I think you may want to spend some time perusing the jargon file

    -derby

Re: what is...
by steves (Curate) on Mar 09, 2002 at 17:13 UTC

    Ever notice how you can often tell who's been on the system by the file names (typically in /tmp on UNIX)?

    I'm a foo/bar/fubar user, having learned that from one of my first co-workers almost 20 years ago. He gave me the WWII explanation for their names and I've been using them ever since. Another guy there used names from The Flintstones, so we always knew he'd been busy when we found fred, barney, and wilma files laying around. A few other guys were Three Stooges fans, etc. What's funny is that years later when these guys give me examples of how to do something they always use the name space I know them for.

Re: what is...
by tjh (Curate) on Mar 09, 2002 at 13:38 UTC

    Lol. Foobar is the encrypted secret password.

    The complete etymology is Here, unless I fouled up the link.

Re: what is...
by Dog and Pony (Priest) on Mar 09, 2002 at 16:38 UTC
    When in wondering about something that is (or seems to be) some kind of internal hacker or computer joke, always turn to The Jargon File. A quick lookup gives us: foo, bar and foobar.

    Good explanations from a hacker perspective, lots of cross-references and examples of other metasyntactic variables. :)

    Hope that gives something of an explanation. As for when used in perl programs, they are usually example, or temporary, mockup variables. :)


    You have moved into a dark place.
    It is pitch black. You are likely to be eaten by a grue.
Re: what is...
by ProgrammingAce (Sexton) on Mar 09, 2002 at 14:25 UTC
    Then there's always the World War II version of what it means, but i'll let you figure out what that was... (Saving Private Ryan came closest).

            - Ace "Two programmers walk into a bar, the third ducks"
Re: what is...
by ignatz (Vicar) on Mar 09, 2002 at 14:29 UTC
    Don't forget $paco
Re: what is...
by shotgunefx (Parson) on Mar 09, 2002 at 19:33 UTC
    LOL. Reminds me of Algebra 1.

    Me: "I don't get it. What is X?"
    Teacher: "X is a variable."
    Me: "What is a variable?"
    Teacher: "It's anything."
    Me: (Blank stare.)


    -Lee

    "To be civilized is to deny one's nature."
Re: what is...
by Seumas (Curate) on Mar 09, 2002 at 21:28 UTC
    Also of significance is that foobar is the phonetic spelling of FUBAR (Fucked Up Beyond All Recognition). A term frequently used in military parlance and adoped by programmers for very obvious reasons.

    ex: "Michael's code is FUBAR."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://150534]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-28 23:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found