[ic] Array of Hashes
Peter
peter at pajamian.dhs.org
Tue May 18 21:27:24 UTC 2010
On 19/05/10 08:10, Rick Bragg wrote:
> Hi,
>
> I want to be able to store an array of hashes in the session, but it
> seems I am having trouble with this. My problem is how do I store a
> hash in the session for later? and how do I access this later on?
>
> i.e. storing:
>
> The array would be something like the following:
>
> [calc]
> @AoH = (
> { sku => "item_101", color => "green", },
> { sku => "item_102", color => "blue", },
> { sku => "item_103", color => "red", },
> { sku => "item_104", color => "gray", },
> );
> $Scratch->{saved_item_hash} = join(' ', @AoH);
$Scratch->{saved_item_hash} = \@AoH;
> return;
> [/calc]
>
>
> Then somewhere else on the page access again later somehow with:
> [calc]
> my @AoH = split(' ',$Scratch->{saved_item_hash});
my @AoH = @{$Scratch->{saved_item_hash}};
> [/calc]
>
> I know this is wrong, but any ideas or best practice for this?
That said, from what it looks like you're trying to do, why not just
save the items in a named shopping cart?
See:
http://www.interchange.rtfm.info/icdocs/tags/userdb.html
http://www.interchange.rtfm.info/icdocs/Interchange_user_database.html#Shopping_carts
http://www.interchange.rtfm.info/icdocs/Interchange_Perl_objects.html#Carts
Peter
More information about the interchange-users
mailing list