Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: What are these?

by qslack (Scribe)
on Apr 20, 2002 at 05:56 UTC ( #160737=note: print w/replies, xml ) Need Help??


in reply to What are these?

Foo and bar are just demonstration variables. They are used just in examples, when the thing being demonstrated is not the actual implementation of the code, but just a concept.

Shift removes the first item from the @_ array (or another array if one is provided to the function, or @ARGV if not used in a subroutine) and puts it in $whatever. So if you had this:
my @foo = ('bar', 'quux'); my $whatever = shift @foo;
$whatever would contain 'bar,' and @foo would contain only the 'quux' element.

edit: thanks thelenm - fixed

Quinn Slack
perl -e 's ssfhjok qupyrqs&&tr sfjkohpyuqrspitnrapj"hs&&eval&&s&&&'

Replies are listed 'Best First'.
Re: Re: What are these?
by dmmiller2k (Chaplain) on Apr 20, 2002 at 13:13 UTC

    Yes, but the actual names 'foo' and 'bar' come from the acronym, 'fubar' (i.e., foobar), which stands for

    Fouled Up Beyond All Recognition.
    Not sure of the actual etymology of the expression, but I heard this from people who are (or have been) in the military (all of whom seem to have heard it).

    Update:: Another acronym in the same family is, 'snafu':

    Situation Normal: All Fouled Up.

    dmm

      Situatinck Nrcknal? ;-)

      After Compline,
      Zaxo

      surely you're just being polite:

      s/o(.)l/$1ck/;
      does the trick :)

      cLive ;-)

Re: Re: What are these?
by thelenm (Vicar) on Apr 20, 2002 at 17:05 UTC
    Of course, if you're not in the lexical scope of a subroutine or format, then shift uses @ARGV by default, and not @_ (as explained in perldoc -f shift).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2023-12-11 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?