in reply to [SOLVED] Troubles with building a hash slice
Your problem is the that $tmpline is a scalar with one value and you are then using it to find the single key '"data1", "data2", ... "data13"'. What you really want to do is the following
while ( $tmpline = <FROM> ) { chomp $tmpline; @data_from = split ';;', $tmpline; @from{@fields_from} = @data_from; while (($key, $value) = each %from) { print "$key => $value\n"; } }
As an aside the substitution would have been better written as
$tmpline =~ s/;;/", "/g; $tmpline = qq{"$tmpline"};
|
|---|