>>>>> "B" == Brian  <fulls...@me.com> writes:

  >> I have an example from Shawn C. from another thread, presented here
  >> out of context.  The code does just what he meant it to do.
  >> It inverts a hash.

  B> Just curious if there is a particular reason Shawn did not use the reverse 
function:

  B> my %hash  = (
  B>           './b/fb'        => 'fb',
  B>           './b/c/fd'      => 'fd',
  B>           './b/l/c/f2'    => 'f2',
  B>           './b/g/f/r/fc'  => 'fc',
  B>           './b/g/h/r/fb'  => 'fb'

  B>       );

  B> my %inv_hash = reverse %hash;

as others have shown, that fails because of the dup value of 'fb'. but
in some cases where you know there are no dups, then reverse is a fine
solution. it all depends on the data and what you want to see when you
invert the hash.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to