Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Next Line Assigning to A Scalar

by GotToBTru (Prior)
on Oct 29, 2014 at 20:38 UTC ( [id://1105553]=note: print w/replies, xml ) Need Help??


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

1 Peter 4:10

Replies are listed 'Best First'.
Re^2: Next Line Assigning to A Scalar
by rmwheeler (Initiate) on Oct 30, 2014 at 13:08 UTC
    Thanks so much for the assistance. I guess this is the best way of explaining it since I have no output.
    Variables ========= $type $color $amount -> for 1st line $type $color1 $amount1 -> for 2nd line if $type matches the 1st line $ +type $type $color2 $amount2 - for 3rd line if $type matches the 2nd $type

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1105553]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-25 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found