>>>>> "RC" == Rob Coops <rco...@gmail.com> writes:

  RC> my $arrayref = [ [ [ 'user1', 'c'], [ 'user2', 'a'], [ 'user2', 'b' ],[
  RC> 'user2', 'd' ],[ 'user3', 'a' ],[ 'user2', 'f' ] ] ];

this comment is for both you and the OP. you should format complex data
so you can read it. it makes it much easier to edit and modify it later
on. i can't tell which level those elements are in so it makes it harder
to code for it.


  RC> my %hash;
  RC> foreach my $arrayreference ( @{${$arrayref}[0]} ) {
  RC>  if ( ! defined $hash{${$arrayreference}[0]} ) {

why do you think you need to check for that?
  RC>   $hash{${$arrayreference}[0]} = { group => [ ${$arrayreference}[1] ] };

  RC>  } else {
  RC>   push @{${$hash{${$arrayreference}[0]}}{group}}, ${$arrayreference}[1];

if you just did that single line and not the if and then parts, it would
still work fine. this is called autovivification. it is one of those
very nice things perl does for you.

also please learn to bottom post and edit the quoted email.

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