From:                   Susan Aurand <[EMAIL PROTECTED]>

> I am learning Perl, so this may seem a dumb question to the advance
> Perl Programmers. What exact purpose does $foo do? Example $foo=$_.
> What benefit do I get  from making the input string $foo? Every place
> I look I do not get a clear understanding or picture of $foo. Thank
> you Susan

I think it's good to think about $_ as if it was a pronoun "You".

        s/hello/hi/g;   === "Hey you there change all "hello"s to "hi"s!"
        chomp;                  === "Hey you drop the end-fo-line!"
        ...

Now it you only work with one variable and the part of code is short 
it's OK to use $_ ... since you'll know which "you" do you mean. 
But as soon as the code gets more complex, you pass the variable 
around or you have some internal loops with their own "you" ... 
you'll soon loose track who are you shouting at at the moment.

Then it's good to name the variable at last. So that you know when 
do you speak to Mary and when to Robin :-)

Jenda

P.S.: If the question was more about "why the heck do they use 
"foo", what does that name mean." ... then .. the name foo doesn't 
mean anything. Foo is used in place of a real name of variable in 
examples and similar places. Basicaly it's also kind of ... pronoun.

=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
                                        --- me

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to