in reply to Re: WHAT IS WRONG TO PASS PARAMETER TO THE ARRAY?
in thread WHAT IS WRONG TO PASS PARAMETER TO THE ARRAY?
sub { #8test5 my $incomddata= $_[0]; return($incomddata); } i then call this sub and print the $incomdata in main script. i was ge +t what a wanted. as i said before $incomddata is from a loop so i was give a list of value when i print it out. it shows the data h +as been sucessfully passed into $incomddata <code> here is another sub while it runs well. however i don't understand what is wrong with first sub. i really try to fix the problem of first sub as it is easy for me to format output data layout. <code> sub { # this sub is a workable # splits them up into stuff like "{name => 'name222',colour => 'yellow +'}" my @split = (split /\Q},{/, $_[0]); my @loop; foreach (@split) { s/^{//; s/}$//; my $hash; my $hash1; my @tmp = split /,/, $_; # now lets split them at ', my @subloop; foreach my $tmp (@tmp) { my $hash; my ($name,$value) = split / => /, $tmp; $hash->{name} = $name; $hash->{value} = $value; $hash->{value} =~ s/^\'//; $hash->{value} =~ s/\'$//; push @subloop, $hash; } #$hash1->{name} = "subtotal"; #$hash1->{value} = "999"; #push(@subloop, $hash1); push @loop, { subloop => \@subloop }; } return { split_loop => \@loop }; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: WHAT IS WRONG TO PASS PARAMETER TO THE ARRAY?
by ig (Vicar) on Aug 06, 2009 at 11:37 UTC |