in reply to How can I write and call subroutines in separate files?

When I try this, I get "Can't locate test2.pm in @INC". My main file is called "test.pl", and the second file with the subroutine in it is called "test2.pl". Here is "test.pl":
#!/usr/bin/perl -wT $|=1; print "Content-type: text/html\n\n"; use CGI::Carp('fatalsToBrowser'); use strict; use warnings; use CGI qw(:standard); use test2; $CGI::DISABLE_UPLOADS = 1; $CGI::POST_MAX = 51_200; $|=1; print header( "text/html" ), start_html(-title => "Hello World"); test2::hello(); print end_html();
Here is "test2.pl":
#!/usr/bin/perl -wT package test2; sub hello { print "HELLO!\n"; } 1;
Is this something with the way my web server is setup that it doesn't allow multiple files or is it just a code problem? Thanks in advance.

Replies are listed 'Best First'.
Re: Answer: How can I write and call subroutines in separate files?
by Roger (Parson) on Oct 08, 2004 at 02:33 UTC
    You are asking the question in the wrong place. Ask in the Seekers of Perl Wisdom section, not here. For your reference, the perl package should end with .pm extension, and then in your test.pl, add the directive use lib "./" before use test2;