You seem to be misunderstanding how && works in this case. When you say:
$_ =~ /a/i && /e/i && /i/i && /o/i && /u/ithat essentially gets extrapolated to:
($_ =~ /a/i) && ($_ =~ /e/i) && ($_ =~ /i/i) && ($_ =~ /o/i) && ($_ =~ /u/i)Then when you write:
$one_line =~ /a/i && /e/i && /i/i && /o/i && /u/iit similarly gets extrapolated to:
($one_line =~ /a/i) && ($_ =~ /e/i) && ($_ =~ /i/i) && ($_ =~ /o/i) && ($_ =~ /u/i)Notice how all the subsequent matches look in $_? The only reason your first example works is because the match operator defaults to matching against $_. The solution is either to bind each and every match to the variable you want to match, or to combine all the regexes into one, like so: $one_line =~ /a|e|i|o|u/i.
Update: replies pointed out that my combined regex was not the same as the original intent.
Update: I've posted a single-regex solution deeper in the thread. It may have problems that I'm not aware of, but seems to test out OK.
In reply to Re: $_ works, $my_variable doesn't?
by revdiablo
in thread $_ works, $my_variable doesn't?
by C_T
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |