Hi.
I am currently in a position where I am having to learn Perl in the context of developing a website using Embperl. I am at a point where I have a few subroutines that I would like to try off-loading to a separate file and then including that file on pages where those subroutines are to be used.
I understand that creating a Perl module/package may be more desireable, but for the purposes of this topic, I am trying to figure out how to get 'do' to work. Feel free to make comments and recommendations as far as creating a package instead though because the more information I have while I learn, the better.
To test the basic functionality, I created two files. lib.pl and testlib.bhtml. In our environment, bhtml files are HTML files that contain Embperl code.
lib.pl:
sub libTest {
$out=shift;
return "libTest says \"".$out."\"";
}
1;
testlib.bhtml:
[! do "./lib.pl"; !][## I have tried lib.pl, "lib.pl", "./lib.pl", and ./lib.pl with the same result ##]
Output: "[+ libTest("test") +]"
When I try to load testlib.bhtml in the browser, I get the following error:[31333]ERR: 24: Error in Perl code: Undefined subroutine &Embperl::__6::libTest called at /home/david/www/testlib.bhtml line 2.
Can anyone tell me what I may be doing wrong. Also, in the error code above, what is the significance of the string "::__6"? That "6" cycles (seemingly randomly) between 6, 7, and 2 as I continue to refresh the page.
Thanks in advance for any help!
Dave