It doesn't work because your hash hasn't been created at the time you try to assign to the letter and plain keys. If you're using strict, perl will complain loudly about that.
You can do what you're after, but you need to do it in two steps. The first step is to create your hash with the bond key in it, and the second step is to fill in the other values. For example:
my %media = (bond => "USLetter:Plain:white:75");
%media = (%media,
letter => $media{bond},
plain => $media{bond});
This does what you're after. Putting %media as the first entry when re-assigning the hash makes sure that the old values are put back in.
Of course, TMTOWTDI. The following is probably faster (as we're not copying the hash back into itself), and more compact, but more difficult to understand.
my %media = (bond => "USLetter:Plain:white:75");
@media{qw/letter plain/} = @media{qw/bond bond/};
Cheers,
Paul |