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:

Every successful person has had failures but repeated failure is no guarantee of eventual success.

Working...