UBB.Dev
Posted By: Baby Jordan incluzion of .txt filez - 07/05/2001 2:10 PM
how du u include a .txt file within a perl script?
Posted By: tackaberry Re: incluzion of .txt filez - 07/05/2001 3:27 PM
If by include, you mean to read-in an external file, you would use the Open command.

open FILEHANDLE, EXPR


-Tacks
Posted By: The Donut Re: incluzion of .txt filez - 07/06/2001 6:54 AM
if that file has extra info that helps the script run, then use:

require "file.txt";


and call the contents of the file like it was part of the sub your in.

or if you just want to display the contents of the text file, use something like:

open (FILE, "file.txt") or die "cannot open file.txt: $!";
$text = ;
close(FILE);

print "$text";

Note to Borg(if you ever read this): perl ubb code tags don't work well if you have two instances in the same post. prints the last instance in all the instances.

[ July 05, 2001 11:57 PM: Message edited by: The Donut ]
Posted By: CNCR Re: incluzion of .txt filez - 07/27/2001 11:48 PM
there is no need to require the file...
Posted By: CNCR Re: incluzion of .txt filez - 07/27/2001 11:49 PM
and if the file had CGI in it, you would still be printing it out as text, not executing the CGI. (duh)
Posted By: The Donut Re: incluzion of .txt filez - 08/02/2001 12:01 AM
Well, if you use require(), then it is executing, not printing, given that the file you're requiring is written in Perl also. It would print as text only if you used the open() method.

I remember this very well, because in php, if you require() or include() a file, if ther are no tags, then it prints it as text. Perl doesn't work that way. You ever notice how ubb treats files when it require()'s them? wink smile

Just pointing that out..

[ August 01, 2001: Message edited by: The Donut ]
© UBB.Developers