AFAIK you have to do the two steps of (A) splitting on the delimiter (B) doing the hash assignment - so reducing it to a one liner, if possible, wd be a cosmetic exercise.
update: err... ok, reviewing the other posts I realise that one
can do it in one step - so I live and learn! Sorry to be misleading. Meantime, back with the rest of my original post:
But n.b. that however you do it you need to declare your hash outside the loop because otherwise each assignment will be a new hash (and also you have to declar a hash as a hash, not during the assignment, so what you have doesn't even do what it's
not meant to do).
You cd shorten it down to
my ($N, $V, %hash);
for (@line) {
($N, $V) = split /delim/;
$hash{$N} = $V;
}
§
George Sherston