in reply to Re^2: How to assign an array to a value in hash?
in thread Re: How to assign an array to a value in hash?
open(DATA1,"<Switcher.properties"); open(DATA2,">FileWrite5.txt") ; while(<DATA1>){ print DATA2 $_; } close(DATA1); close(DATA2); open(DATA1,"<Switcher.properties"); my @Lines=<DATA1>; my %myHash; my @keys; my @y; my @values; my $p=0; my @i; my @x; my $k; foreach my $val (@Lines) { #print "$val"; @i=split('=',$val); $x=0; @keys=@i[x]; @values =@i[$x+1]; print " Keys --> @keys values --> @values \n"; @keys = @i[$x+2]; my $z= @i[$x]; print " The z value--> $z\n"; foreach my $val (@values) { if($val=~m/,/){ @y= split(',',$val); $k=0; foreach my $q (@y){ $myHash{$z}=$q ; print " The value of q --> $q The key for that is --> @i[$x] \n \n "; } print " Key --> @i[$x]\n Multiple values for the key are --> @y "; $k++; } } $x++; $p++; } print " Hash values are as below \n"; while ( my($key,$value)= each %myHash){ print "$key : $value\n " ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to assign an array to a value in hash?
by AppleFritter (Vicar) on Mar 09, 2015 at 11:03 UTC | |
by vukotid (Initiate) on Mar 09, 2015 at 12:31 UTC | |
by AppleFritter (Vicar) on Mar 09, 2015 at 21:23 UTC | |
by vukotid (Initiate) on Mar 10, 2015 at 04:48 UTC | |
by AppleFritter (Vicar) on Mar 10, 2015 at 09:40 UTC | |
|