Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
This won't compile:
Dropping the () around $what will make it compile, but that really changes what the code is saying. is going to try to find the value in %what that is assosciated with the key '3' and use that as a regex. Unless you have some %what hash, this will be undef and will be intrepreted as which will match anything, including nothing. Essentially, that's just and you most likely do not want that. This probably does the closest to what you want (match three occurrences of 'fred' or 'barney' in any order. This works because =~ treats whatever it finds on the right hand side as a RE (regular expression). You could get the same behavior from either of your examples by using the m// operator (the 'm' can be omited if you are using slashes as the delimiter). If you do this, then you can eliminate the '$_ =~' as it is redundant:
Ivan Heffner Sr. Software Engineer, DAS Lead WhitePages.com, Inc. In reply to Re: I'm reading a book! It's given me more questons!
by Codon
|
|