Forgot your password?
typodupeerror
User Journal

Journal eglamkowski's Journal: neat 3

I don't write perl scripts very often, and when I do they usually aren't anything fancy. So this may seem quaint or elementary to some of you, but I was quite delighted to discover I could do this:

push(@{ $hash{"KEYNAME"} }, "value1");
push(@{ $hash{"KEYNAME"} }, "value2");
push(@{ $hash{"KEYNAME"} }, "value3");
push(@{ $hash{"KEYNAME"} }, "value4");
 
foreach $string (keys %hash) {
    print "$string: @{$hash{$string}}\n";
}

That is to say, a hash where the "value" part of the key-value pair was an array instead of a scalar.

Neat.

This discussion has been archived. No new comments can be posted.

neat

Comments Filter:

"In the long run, every program becomes rococo, and then rubble." -- Alan Perlis

Working...