when I realized that I wanted to map field3 to two different things, and that I actually had the keys and values backwards, but conceptually I still wanted the order to be the way I had it (because I was mapping a source to a target, and the source might have more than one target), so to save some typing (there were more than just 3 fields), I changed the hash ref to an array ref, and did a reverse on the array to build a new hash ref. I probably wouldn't do this in a loop; it was just a one time initialization thing. But what I really wanted was to be able to go:my $href = { field1 => 'this', field2 => 'that', field3 => 'another', ...
Any thoughts on whether this is a good idea? Or should I just shut up and reverse my keys and values or the array ref? Duh, I just realized its a 'less than or equal to' operator, but still, could it be easily overloaded (or be some other operator entirely)?my $href = { field1 <= 'this', field2 <= 'that', field3 <= 'another', field3 <= 'YetAnother', ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: The Oops operator.
by tilly (Archbishop) on Jul 26, 2001 at 23:27 UTC | |
by runrig (Abbot) on Jul 26, 2001 at 23:35 UTC | |
|
Re: The Oops operator.
by dragonchild (Archbishop) on Jul 26, 2001 at 23:27 UTC | |
by runrig (Abbot) on Jul 27, 2001 at 00:56 UTC | |
by John M. Dlugosz (Monsignor) on Jul 27, 2001 at 00:10 UTC | |
by dragonchild (Archbishop) on Jul 27, 2001 at 00:14 UTC |