in reply to Re^2: can i rename hashref keys?
in thread can i rename hashref keys?
Given that delete can delete a slice, this can be simplified:
my %map = (...); @$h{values %map} = delete @$h{keys %map};
Update: note that this doesn't break on %map = (foo => 'bar', bar => 'foo') that the solutions above may do.
lodin
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: can i rename hashref keys? (...simplified)
by tye (Sage) on Nov 29, 2007 at 17:42 UTC |