in reply to Constructing a hash - why isn't my regex matching anything

The match operator (m//), in scalar context ( my $foo = m//;) , returns the number of matches ( in your code/data, 1 for key, 1 for value).

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