The solution is to either use $1 for assignment if( // ){ $key = $1; ...) or use list context ( my ( $foo ) = //;)
Tutorials: Context in Perl: Context tutorial
FYI, when posting
In reply to Re: Constructing a hash - why isn't my regex matching anything
by Anonymous Monk
in thread Constructing a hash - why isn't my regex matching anything
by perl_mystery
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |