[ic] Cart programming question

Steffen Dettmer interchange-users@interchange.redhat.com
Sun Mar 17 11:03:01 2002


Hi,

thank you for your very quick reply! And this on a sunday! Thank
you very much!

* Mike Heins wrote on Sat, Mar 16, 2002 at 16:02 -0500:
> Quoting Steffen Dettmer (steffen@dett.de):
> * Mike Heins wrote on Thu, Feb 14, 2002 at 14:32 -0500:
> > If you want to use embedded Perl with safe, it is OK to do
> > 
> > [try]
> >     [calc]
> > 	$Carts->{main} = <<'EOF';
> > [data table=group_carts column=content key=cart_id]
> > EOF
> >     [/calc]
> > [/try]
> 
> This should actually be:
> 
> 	$Carts->{main} = 
> 	 [data table=group_carts column=content key=cart_id]
> 	;

Again, this leads to: 

Can't use string ("[{"price_group" => "general","mv") as an ARRAY
ref while "strict refs" in use at
/usr/local/interchange-4.8.2/lib/Vend/Interpolate.pm line 1268.

since it assigns a scalar string to the cart, but the cart has to
be an array reference containing hash references. I mean the
difference is the same as in:

$string = "[ 1, 2, 3 ]";
$array_ref = [ 1, 2, 3 ];

I can do $array_ref->[0] but of course not $string->[0]. string
"looks" like an array, but it is just a string.

I need something like

$arrar_ref = eval($string);

but eval is not available. The UserDB.pm uses a function called
"reval" from Module Safe for doing the trick (if I read the
sources correctly). Should / can I use that function, too? At
least a use something; isn't allowed in pages I've read. I think
I should try it in a global user tag? Should I do a 

use Safe; 
$ready = new Safe;
$arrar_ref = $ready->reval($string);

or is there a better way? Maybe I should just try it...

If I copy and paste the cart content from the DB to the source
page, like:

$Carts->{main} = <<'EOF';
[{"price_group" => "general","mv_ip" => "0","mv_ib" =>
"products","code" => "0:76001","gift_cert" => "","quantity" =>
"10",},{"price_group" => "general","mv_ip" => "1","mv_ib" =>
"products","code" => "0:CU67575","gift_cert" => "","quantity" =>
"20",},]
EOF

The cart is working. But if I use a variable here, it gets
assigned as scalar string and not as nested data structure.

I hope I made my problem/question more clear now. I need some
method to evaluate a string to the nested data structure, as
the standard perl "eval" does it.

Any ideas or hints? Thank you!

oki,

Steffen

-- 
Dieses Schreiben wurde maschinell erstellt,
es trägt daher weder Unterschrift noch Siegel.