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

Timothy Cassidy 6tc1@qlink.queensu.ca
Thu, 15 Feb 2001 01:49:08 -0500 (EST)


Hey thanks alot for the advice - I'm now able to call procedures in user
tags, but I still don't seem to be able to "use" my JVM module.  I tried
using the "use" syntax:

UserTag java_code Routine   <<EOF
sub {
        use JVM;
return "testy testy";

}
EOF

But this didn't work and nothing gets reported in my:
/tmp/icdebug
file except for a log of when I restart the server:
Start DEBUG at Thu Feb 15 00:10:50 2001

Anyway, after that failed, I tried to adapt your shipping subroutine that
you sent me to my purposes:

UserTag java_code Routine   <<EOF
sub {
        require MV::JVM;
return "testy testy";

}
EOF

This also didn't work - is there any sort of a tutorial on the syntax of
writing these subroutines?  Specifically on how to import modules.  Once I
have access to the JVM module, I know the code I need to write in perl.

Thanks for all of your help,
Tim Cassidy

On Mon, 12 Feb 2001 cfm@maine.com wrote:

> > 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";
> > }
> > EOF
>
> 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;
>         my($M,$adj,%opt);
>
>         $opt{config}=$Vend::Cfg->{CatalogName};
>         $adj=0;
>         $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;
> }
> EOF
>
> 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;
> > }
> > EOF
> >
> > 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
>
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@lists.akopia.com
> http://lists.akopia.com/mailman/listinfo/interchange-users
>