sub { #8test5 my $incomddata= $_[0]; return($incomddata); } i then call this sub and print the $incomdata in main script. i was get 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 has been sucessfully passed into $incomddata 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. 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 }; }