[ic] Want to use new module/library in embedded Perl code

cfm@maine.com cfm@maine.com
Mon, 12 Feb 2001 21:58:16 -0500

> The best I was able to do was create a GlobalSub in the interchange.cfg
> file:
> GlobalSub <<EOF
> sub count_orders {
> return "this is returned from count_orders subroutine.\n";
> }

You don't have these modules, but the syntax is the same.
I'm pretty sure you can "use" (vs "require").

## merchants_shipping

UserTag merchants_shipping Order base
UserTag merchants_shipping Routine <<EOF
sub {
        require MV::Merchants;
        require MV::Shipping;

        $M=&MV::Merchants::load_merchant(\%opt,$Vend::Session->{values}); # stubbed everywhere
        $opt{shipping_rules}=$M->{$opt{config}}{shipping_rules} if defined($M);
        $adj+=&MV::Shipping::base_item_shipping(\%opt,$opt{shipping_rules}) if ($opt{shipping_rules});
        $adj+=&MV::Shipping::extra_item_shipping(\%opt,$opt{shipping_rules}) if ($opt{shipping_rules});
        $adj+=&MV::Shipping::gift_certificate_shipping(\%opt,$opt{shipping_rules}) if ($opt{shipping_rules});
        return $adj;

Frankly, I think
the issue is you are taking too big a first bite.  Write a
little perl module that just opens, writes and closes a file.
Call that perl module.  Get it to work.  They are all the same 
after that.

> So then I tried creating a regular subroutine in the interchange.cfg file:
> Sub <<EOF
> sub sort_cart_by_quantity {
> my $out = 'This is a test!!!';
> return $out;
> }
> But again I couldn't call it from my embedded perl code in my html pages:
> [perl]
> return sort_cart_by_quantity();
> [/perl]

Is that right?  I bet you created a nameless sub that has
a compiled sub in it, sort_cart_by_quantity.  I'm not sure about
that Sub syntax in cfg - never used it.  Check Config.pm and see
how it gets parsed.


Christopher F. Miller, Publisher                             cfm@maine.com
MaineStreet Communications, Inc         208 Portland Road, Gray, ME  04039
1.207.657.5078                                       http://www.maine.com/
Content management, electronic commerce, internet integration, Debian linux