foreach my $pair ( pairs /(\d+)\s+(\S+)/mg ) { my ( $key, $value ) = @$pair; ... } #### $h{ $1 } = $2 while /(\d+)\s+(\S+)/mg;