[thelist] perl question: do|require|use.. other?

Kirk Lashley kirk at coraldesigns.com
Wed Jul 16 15:38:13 CDT 2003


This may sound dumb to those who've been working in perl for years. 
 I've only been at it for weeks.  I'm trying to build a web application 
by writing lots of different functions, and putting them in different 
files.  Each component compiles correctly when run from the command 
line.  Now, I use the do() command to include these other files at the 
beginning of each script, but it doesn't look like do() does what I want 
it to do.  For instance I put all my ¨use strict; use CGI; ... ¨ 
statements in one of the included files, but that caused errors until I 
pulled them back into the main script.

Also, I'm defining global variables in another include file, header.pl, 
however - the main script doesn't like that.  do() looks like it is 
executing the script at that line and then discarding it.  What command 
should I use to load/include another external file?
Is there something similar to php's include(¨filename¨);  Should I be 
using use() or require() instead?

- Kirk



More information about the thelist mailing list