rooneyl has asked for the wisdom of the Perl Monks concerning the following question:

I have written a sample program using Mason and my own pm file. I am having problems with things not being found, any clues please.
The html code is;
<%init> use strict; # path to modules use lib "usr/local/www/apache/htdocs/TEST"; # modules to use use check; </%init> <html> <body> <h1>hello there</h1> % my $test1 = check::one(); % if ($test1 eq 'yes') { <h3>test 1 ok</h3> % } % my $test2 = check::two(); % if ($test2 eq 'two') { <h3>test 2 ok</h3> % } % my $test3 = check::three(); % if ($test3 eq 'three') { <h3>test 3 ok</h3> % } % my $test4 = check::four(); % if ($test4 eq 'four') { <h3>test 4 ok</h3> % } % my $test5 = check::five(); % if ($test5 eq 'five') { <h3>test 5 ok</h3> % } % my $test6 = check::six(); % if ($test6 eq 'six' ) { <h3>test 6 ok</h3> % } <h4>Version is: <% $check::VERSION %>.</h4> </body> </html>
Perl mod code is;
package check; use strict; require Exporter; our @ISA = ('Exporter'); our @EXPORT = ( 'one','two', 'three', 'four', 'five', 'six' ); our $VERSION=1.10; sub one { return 'yes'; } sub two { return 'two'; } sub three { return 'three'; } sub four { return 'four'; } sub five { return 'five'; } sub six { return 'six'; } 1;
Error message from browser is;
line 49: Undefined subroutine &check::six called context:
...
45: if ($test5 eq 'five') {
46: $_out->('

test 5 ok


47: ');
48: }
49: my $test6 = check::six();
50: if ($test6 eq 'six' ) {
51: $_out->('

test 6 ok


52: ');
53: }
...

Thank you in advance.

Replies are listed 'Best First'.
Re: Mason problems
by perrin (Chancellor) on Jul 07, 2008 at 15:46 UTC
    Your use lib has a relative path. It should begin with a slash.
Re: Mason problems
by thezip (Vicar) on Jul 07, 2008 at 23:05 UTC

    If possible, try restarting the webserver after making changes to any of your modules. This will force the used modules to be reloaded by Apache/mod_perl.

    I've seen some strange results when I've not restarted the webserver.


    Your wish is my commandline.
Re: Mason problems
by Anonymous Monk on Jul 07, 2008 at 14:34 UTC
    So it finds one through five ok? Probably check is being cached :)
      Sorry, should have said the function causing the error seems to be random (it will work sometimes). I don't think it is a cache problems with the browser as it still throws an error even if you force a reload from the server.
        The browser doesn't know about modules :) check, the module, is maybe being cached by the server (mod_perl, and maybe differently by each child).