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