lol. This should help explain.

http://whatis.techtarget.com/definition/0,,sid9_gci212139,00.html

When you see something like 

$foo = $_;

It means that someone is taking the value of the default variable ($_) and
assiging in to another scalar. In this case, $foo, but it could just as
easily be $someName.

The default variable is more often than not invisible in scripts. For
example

@array = qw(one two three);

foreach (@array) {
        print;
}

In that code, then default variable appears twice. Can't see it?? That's
because most of the perl operators default to working with the default
operator if no other is assigned.

The code above does exactly the same as this

@array = qw(one two three);

foreach $_ (@array) {
        print $_;
}

And if you want make it clear which variable you are working with you can do
either

@array = qw(one two three);

foreach $someName (@array) {
        print $somName;
}

which assigns each element in turn to $someName or...

@array = qw(one two three);

foreach (@array) {
        $someName = $_;
        print $someName;
}

which assigns each element in turn to $_, then you are taking that value and
assiging it to $someName within the loop and working with that new value.

HTH

John

-----Original Message-----
From: Susan Aurand [mailto:[EMAIL PROTECTED]]
Sent: 15 February 2002 14:49
To: [EMAIL PROTECTED]
Subject: $foo


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



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


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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

Reply via email to