RE: Perl Question : How To Include?

by "Brian A. Sayrs" <sayrs(at)southwindsolutions.com>

 Date:  Mon, 31 Jan 2000 16:19:49 -0800
 To:  "'SDJThorin'" <sdjthorin(at)geocities.com>,
"hwg-techniques(at)hwg.org" <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
Two possibilities:

1) it is traditional that header files end with some true statement so =
that the interpreter knows that your file compiled correctly, so adding:

1;	#the number one and a semicolon to indicate that the script compiled =
correctly

to the very end of wyleside.pm (outside of any subroutines you have) =
would be a quick way of ensuring that the require statement works =
correctly.

2) If that's not the problem, then the only thing I can think of offhand =
is to make sure that the perl interpreter knows where wyldeside.pm is =
at.  If it is in the same directory as the running script, it SHOULD be =
OK, but if it is somewhere else, you should put that other directory =
into your @INC array.

The @INC array holds path information for the script, and normally =
includes ".", so the current directory isn't normally a problem.  Using =
my site as an example, every script I have for my message boards and the =
game on that site includes this line:

push @INC, "../cgi-bin";

so that my general-use scripts can be available for both my boards which =
are in the /boards directory, and the game which is in the /conflict =
directory.

HTH,=20
Brian


-----Original Message-----
From:	SDJThorin [SMTP:sdjthorin(at)geocities.com]
Sent:	Monday, January 31, 2000 12:36 PM
To:	hwg-techniques(at)hwg.org
Subject:	Perl Question : How To Include?

Good day list,

I've just started using perl and have a question that I can't
seem to find in any of the references that I have.

Scenario :
	I have a some DBs, flat-text based, for which I have
	created a maintance cgi for, based off of this source :
	 - http://webreview.com/pub/98/10/23/perl/index.html

	I'm trying to add some external header/footer format
	functions, for different theme area, adding the location
	for this into the main config file.

	I've tried using both require & use, as follows :

		$dbfmtfile=3D"wyldeside.pm"; (From Config File)

		require $dbfmtfile

	and

		## Load Databse Format Functions
		if (-e $dbfmtfile)
		{
			require $dbfmtfile
		}
		else
		{
			&print_cfg_error($dbfmtfile)
		}

	I have separate files for each theme, that contain these
	functions :
		- sub Print_Header{block}
		- sub Print_Break{block}
		- sub Print_Footer{block}

	The thing is, it doesn't seem to be able to find the files.

	If I put a set of the functions into the main cgi then all
	works normally. So it's not a coding error.

Question :
	Is there something special you need to do to include
	external "sub FuncName{block}"s?

Thanks, in advance,

	Stephen.

 ----------------------------------------------------------------
 |   /~\      ^| |^      /~\    The WyldeSide                   |
 |  /   /\   (o) (o)   /\   \       Web Designs & Programming,  |
 | |   |  | (  o~o  ) |  |   |      For Your Needs              |
 | \   \   \  ) O (  /   /   /  http://www.wyldeside.com        |
 ----------------------------------------------------------------

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.