Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

quick perl question



<jabr at blu.ORG> scribbled:

	On Thu, 10 Feb 2000 Phil Buckley <phil at infoinsomniax.com> wrote:

	> A bit off topic, but I know someone out there will have this on the top
	> of their head... 
	> 
	> I want to pull in a cgi script that holds a handful of common functions.
	> I thought the proper syntax was something like: 
	> 
	> #!/usr/bin/perl
	> 
	> use "common.cgi";
	>
	> but apparently it isn't.
	> 
	> Can someone please gimme a quick dope-slap and remind me.

	*thwap*

	    use CGI qw/:standard/;

Nice slap, but wrong answer.  This doesn't do the same thing at
all, and it's not what was asked for.  More likely, the answer
should be:

	require "common.cgi";

This will read in the file, and compile its contents into the
program.  It's a run-time command, unlike "use", which happens
at compile time.  The "use" command also does some other things
that you probably don't want done if you're just trying to load
in a few of your own routines.

Note that "common.cgi" should end with:
	1;

The require command expects a return value that tells it whether
the package thinks it was loaded successfully.  This tells require
that everything was loaded OK (and a second require of the same file
will be a no-op).

-
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at blu.org (Subject line is ignored).




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org