[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ic] Newbie: constructing Perl subroutines that use CPAN and other external modules


Jeff Boes wrote:

Can someone point me to examples of constructing Perl functions (either
global subs, catalog subs, whatever) which make use of CPAN or other
external modules? For example, I'm trying to use Date::Manip:

sub foo {
 ...
 &Date::Manip::Date_Init();
 ...
}

I have a "require Date::Manip" directive in my interchange.cfg file, I
have a "use Date::Manip;" inside the function body. The function gets
called at the appropriate time, and I get this error:

Safe: Can't locate object method "new" via package "IO::File" (perhaps you forgot to load "IO::File"?) at /usr/local/lib/perl5/site_perl/5.8.3/Date/Manip.pm line 5345.


I added a "require IO::File" directive, and a "use IO::File;" to the
function, but without success. When an external module is loaded at
configuration time, is there some restriction on what additional
external modules it can use?
Jeff,

Access to outside modules and such is limited, depending on the context. If you're writing a catalog-level sub, usertag, etc., then you're limited by the Safe module -- everything in this context runs under Safe, and thus only has a limited number of objects available and no ability to use external modules.

If you want to use the Date::Manip module, you need a global-level routine, be it a globalsub, actionmap, usertag, or filter. By global-level, you define them at the interchange level rather than the catalog. It could be an include or the actual code definition right in your <IC_ROOT>/interchange.cfg file.

My understanding of putting require directives in your interchange.cfg file is that it will try to make sure that the module is available when the Interchange daemon starts, but it doesn't mean much beyond that -- you would still need to implement your code in the manner described above. I've not looked into this specifically, however, so perhaps someone will post a correction to this assertion.

- Ethan

--
Ethan Rowe
End Point Corporation
suppressed

_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.