Brent Clark wrote:
> Hi list
> 
> Would someone be so kind as to share some light on this for me.
> 
> I have the following code:
> 
> ($fileName) = ($_ =~ /regexcode/o);
> 
> Which gives me the correct data.
> 
> But if I make it like so (note the () missing around the variable):
> 
> $fileName = ($_ =~ /regexcode/o);
> 
> Whats the difference.

The parens on the left side place the assignment operation in "list
context". This means the right-hand side (the regex match) will be evaulated
in list context, which gives different results then when it's evaluated in
scalar context (as in the second example).

You can read the section on "Context" in perldoc perldata for more details.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to