A
Alexandra
Tad McClellan said:That is what we are focusing on here as well!
You needed a m// in list context to get what you wanted.
I will play with this because I do want to understand all the different ways
to accomplish the same things (in some cases).
From p69 in the 3rd Camel:
Assignment to a list of scalars also provides list context
to the righthand side, even if there's only one element
in the list.
I have that book open right now on my desk and after reading this, I looked
down to see it was already open to p.69 (not a lie). Out of curiosity, I was
trying to get my "wrong" expression to evaluate to 2 or 0 or any other
number besides 1. But I couldn't do it. I was attempting this by adding in
more elements in the original search string that would match the re, but I
still received a 1.
$mystring = ('xxx blah=bleh @', 'yyy bloh=bluh @', 'zzz blea=blech @');
$mymatch = $mystring =~ /=(.*?)\s/; #for example (one of the
correct solutions previously provided) returns 1
($mymatch) = $mystring =~ /=(.*?)\s/; #returns 'blech', the last
value to match in the string
($foo) = ...list context...
has only one element in the list.
Would you know how to get it to return 3 instead of 1?
(I know, I've got to read and keep at this to understand lists and contexts.
The advanced and even not-advanced programmers reading this must be laughing
at me but if I can learn it then its worth it.)
Alexandra