in reply to Long Versions
The correct translation of the if() statement, using your $line variable would be
if ($line =~ /a/i && $line =~ /e/i && $line =~ /i/i && $line =~ /o/i +&& $line =~ /u/i) {
Where you're going wrong is that && does not combine matches into a single match, it just does a logical AND of the results of the matches.
And any // match without a preceding $variable =~ statement matches on $_, the "implicit"/"default"/"this" variable.
So your original translation boils down to *) - see update 2
if ($line =~ /a/i && $_ =~ /e/i && $_ =~ /i/i && $_ =~ /o/i && $_ =~ +/u/i) {
update: personally, I find the PP book's version much easier on the eyes, and it's definitely more readable once you're used to seeing // matches without explicit $variable =~ parts, but I agree it crams a lot of meaning into a very short line.
The Camel book tends to be like that: it favours idiom over explicitness. IMHO the 3rd edition is a little gentler in this regard, especially in the beginning of the book.update 2: Sidhekin pointed out that your line actually does something else. Here is your line:
Note that you're trying to use the result of (/a/i && /e/i && /i/i && /o/i && /u/i) (which will probably 1 or undef) as a match on $line.$line =~ (/a/i && /e/i && /i/i && /o/i && /u/i)
|
|---|