CGI Include
Just wandering,
In php, to include a file you use the command
include("filename.ect");
What (if anything) would be the perl equivalent to that?
Thanks for the help,
TheSpaceDude
[email protected]
http://www.thespacezone.com
Just wandering,
In php, to include a file you use the command
include("filename.ect");
What (if anything) would be the perl equivalent to that?
Thanks for the help,
TheSpaceDude
[email protected]
http://www.thespacezone.com
japhy posted this at 15:51 — 20th October 2000.
They have: 161 posts
Joined: Dec 1999
You probably want the require() function, or perhaps the do() function. Be warned, files included into your program should end with the line
1;
because Perl expects them to return a true value (that indicates success).
fairhousing posted this at 02:26 — 21st October 2000.
They have: 1,587 posts
Joined: Mar 1999
yeah, require will probably do it for u.
Suzanne posted this at 04:00 — 21st October 2000.
She has: 5,507 posts
Joined: Feb 2000
require "file.txt";
require "file2.txt";
require "files.txt";
Most scripts and programmers recommend you have it near the top of the script/program, before the variables, for ease.
Suzanne
P.S. This was edited to correct my brain fart, thank you!
[Edited by Suzanne on 10-21-2000 at 03:23 AM]
japhy posted this at 04:03 — 21st October 2000.
They have: 161 posts
Joined: Dec 1999
No, Suzanne, I'm afraid you can't. require() takes at most one argument, and that argument MUST be the name of a module, or the path to a single file to be included. To include several files at once, make an array of them, and require each element of the array separately:
# pre-5.005 code
for (@files) { require }
# 5.005 and later
require for @files;
Mark Hensler posted this at 04:35 — 21st October 2000.
He has: 4,048 posts
Joined: Aug 2000
How 'bout this:
require "text1.txt","text2.txt";
like:
print "this","and","this";
japhy posted this at 11:22 — 21st October 2000.
They have: 161 posts
Joined: Dec 1999
No, trust me. require does not take a list of files. perldoc -f require
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.