Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



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:

One can search the brain with a microscope and not find the mind, and can search the stars with a telescope and not find God. -- J. Gustav White

Working...