$foo =~ m// returns different thing depending on context.
In scalar context it just returns true if $foo matched the regexp and false if it didn't. In list context it returns a list of the things captured by the regexp.
Declaring a variable like my ( $bar ) = ... forces list context on the right-hand-side of '=', which, in this case forces the match to work in list context.
In reply to Re^4: Str extract the word between the first and the 2nd '|' character
by FunkyMonk
in thread Str extract the word between the first and the 2nd '|' character
by dani_cv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |