perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Perrin Harkins <phark...@gmail.com>
Subject Re: Undefined subroutine error
Date Tue, 14 Apr 2009 17:21:09 GMT
On Tue, Apr 14, 2009 at 12:48 PM, Roberto C. Sánchez
<roberto@connexer.com> wrote:
> As far as loading the module, I have tried:
>
>  - "PerlModule Example::Image" in .htaccess
>  - "use Example::Image;" in the main HTML::Mason component

Either of those should be ok.  If you decide to export the sub later,
you'd need to call it from Mason.

> As far as calling the function:
>
>  - get_image_data('masthead.png', $urls{'img'}, $dirs{'img'});
>  - Example::Image::get_image_data('masthead.png', $urls{'img'}, $dirs{'img'});

Ok, I don't see how the first one could work with the code you've
shown.  You're defining the sub in a package, so you either have to
export it or call it with the fully-qualified path, like you do in the
second case.

If you're not familiar with this stuff, read up on exporting in the
perlmod man page or your favorite Perl book.

If you use the second syntax everywhere, I think this problem will go
away.  The issue is with the sub being available in your current
namespace, not with loading the module.

- Perrin

Mime
View raw message