sub { ### this sub works well. # 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 }; } #### sub { my ($cgi, $session,$product,$tags,$itemmaxtemp,$itemID, $incomingdata); #my @incomingdata = @_ ; #my @incomingdata = $_[0]; #my @incomingdata = (@_); #my @incomingdata = $_; my $incomingdata = split /\Q},{/, $_[0]; #### my @partofcookie= ({name => 'ddd111',quantity => 11,price => '11',colour => '11red',size => '11xxl',itemID => '1111tiem'},{quantity => '2',name => '222gmailoknow',price => '228',itemID => '222item'}); foreach my $product ( @partofcookie ) { ##### $product->{prod_subtotal} = $product->{price} * $product->{quantity}; $tags->{total_price} += $product->{prod_subtotal}; $tags->{itemmaxtemp}=$itemmaxtemp; $tags->{itemID}=$itemID; push @{$tags->{cart_loop}}, $product; } my @xxx; @xxx = @{$tags->{cart_loop}}; return { orderdetail_loop => \@xxx}; }