in reply to Next Line Assigning to A Scalar
From your description it sounds like you want to retain only one color/amount per vehicle type, and that color and amount should be the last one found for each vehicle type. If that's not what you want, re-read your question, and follow-up with a more careful description of what you're after, including sample output.
If that is what you want, this should do it.
my %vehicles; while ( <DATA> ) { chomp; my( $type, $color, $amount ) = split; $vehicles{$type} = [$color,$amount]; } print for map { "$_ @{$vehicles{$_}}\n" } keys %vehicles;
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Next Line Assigning to A Scalar
by rmwheeler (Initiate) on Oct 30, 2014 at 15:41 UTC | |
by davido (Cardinal) on Oct 30, 2014 at 15:59 UTC |