Re: problem in creating a complex hash

2011-05-13 Thread Uri Guttman
> "RC" == Rob Coops 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 an

Re: problem in creating a complex hash

2011-05-13 Thread Rob Dixon
On 13/05/2011 11:11, Agnello George wrote: Hi All I have a small issue in arranging data with a array ref . $arrayref = [ [ [ 'user1, 'c'], [ 'user2', 'a'], [ 'user2', 'b' ],[ 'user2', 'd' ],[ 'user3', 'a' ],[ 'user2', 'f' ] ] ]; i tried the following my %sh ; foreach my $i ( @$arrayref) {

Re: problem in creating a complex hash

2011-05-13 Thread Paul Johnson
On Fri, May 13, 2011 at 01:00:57PM +0200, Rob Coops wrote: > It might not look nice but I would do the following: But it can be cleaned up quite a lot: > #!/usr/local/bin/perl > > use strict; > use warnings; > > my $arrayref = [ [ [ 'user1', 'c'], [ 'user2', 'a'], [ 'user2', 'b' ],[ > 'user2',

Re: problem in creating a complex hash

2011-05-13 Thread Agnello George
On Fri, May 13, 2011 at 4:30 PM, Rob Coops wrote: > It might not look nice but I would do the following: > #!/usr/local/bin/perl > use strict; > use warnings; > my $arrayref = [ [ [ 'user1', 'c'], [ 'user2', 'a'], [ 'user2', 'b' ],[ > 'user2', 'd' ],[ 'user3', 'a' ],[ 'user2', 'f' ] ] ]; > my %has

Re: problem in creating a complex hash

2011-05-13 Thread Rob Coops
It might not look nice but I would do the following: #!/usr/local/bin/perl use strict; use warnings; my $arrayref = [ [ [ 'user1', 'c'], [ 'user2', 'a'], [ 'user2', 'b' ],[ 'user2', 'd' ],[ 'user3', 'a' ],[ 'user2', 'f' ] ] ]; my %hash; foreach my $arrayreference ( @{${$arrayref}[0]} ) { if (

problem in creating a complex hash

2011-05-13 Thread Agnello George
Hi All I have a small issue in arranging data with a array ref . $arrayref = [ [ [ 'user1, 'c'], [ 'user2', 'a'], [ 'user2', 'b' ],[ 'user2', 'd' ],[ 'user3', 'a' ],[ 'user2', 'f' ] ] ]; i tried the following my %sh ; foreach my $i ( @$arrayref) { push (@{$sh{$i->[0]}},{group => [$i->[1] } )