in reply to Next Line Assigning to A Scalar
What form will the output take? Sounds like you want to store color alternatives. How will you use those alternatives? Will you need to sort them? Can there be more than one black car? Do you need to store the number after the color somewhere?
Your post title talks about assigning to a scalar, but I have trouble imagining that as a useful thing. Perhaps use a hash instead? Put the following right after your print statement (inside the foreach loop):
$price_by_type_and_color{$car}{$color} = $amount;
What kind of vehicles are available?
printf "%s\n",$_ for sort keys %price_by_type_and_color; Output: Bus Car Truck
Updates: minor typos and omissions fixed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Next Line Assigning to A Scalar
by rmwheeler (Initiate) on Oct 30, 2014 at 13:08 UTC |