in reply to Re: Hash from package
in thread Hash from package

thanks for the post mate. however thats not quite what im after. that's cheating what you've suggested.
i want those words you added in to come from the hash, not from adding to the print statement.

ie.
%hash => (Engine, 1800cc, Doors, 4, Color, blue)
print %hash
output is:
Engine 1800cc
Doors 4
Color blue

do you see where im coming from?

Replies are listed 'Best First'.
Re^3: Hash from package
by reasonablekeith (Deacon) on Jan 04, 2007 at 09:40 UTC
    I wouldn't call it cheating. You've already hardcoded some text and the hash key. Sagacity's suggestion is perfectly reasonable.

    You're probably asking the wrong question. "How do I get key values from a hash?" is more likely what you're after.

    foreach my $key (keys %$car) { print "$key = $car->{$key}\n"; }
    ---
    my name's not Keith, and I'm not reasonable.