[ic] Catalog subroutines

Caleb Groom interchange-users@icdevgroup.org
Thu May 1 14:52:01 2003


I'm trying to add a catalog subroutine according to the documentation in
"26.94. Sub".  The example there a sort_cart_by_quantity function that
builds a string and returns it.

For practice I'm taking the foundation catalog and adding the number of
items in the cart to the upper right hand section of the page.  Here's my
function as listed in catalog.cfg:

Sub <<EOF
sub show_custom_cart {
 my $out = sprintf("%d item%s", scalar @{$Carts->{main}}, scalar
@{$Carts->{main}} == 1 ? "" : "s");
 return $out;
}
EOF

I call it like so:

Your cart: [perl] return show_custom_cart(); [/perl]

And I receive this error:

[01/May/2003:13:47:42 -0500] fstore /fstore/index.html Safe: Undefined
subroutine &main::show_custom_cart called at (eval 201) line 1.
>
>  return show_custom_cart();
>

Have I missed a step?  Will Safe get in the way here?  How do I get this to
work?