Previous Thread
Next Thread
Print Thread
Rate Thread
#102939 07/05/2001 7:10 AM
Joined: Nov 2000
Posts: 20
Member
Member
Offline
Joined: Nov 2000
Posts: 20
how du u include a .txt file within a perl script?


Yourz truly
Baby Jordan

"Tell theze BadBoy luvvin' b*tchez 2 bring it on"
Sponsored Links
#102940 07/05/2001 8:27 AM
Joined: Nov 2000
Posts: 2,759
Pooh-Bah
Pooh-Bah
Offline
Joined: Nov 2000
Posts: 2,759
If by include, you mean to read-in an external file, you would use the Open command.

open FILEHANDLE, EXPR


-Tacks

#102941 07/05/2001 11:54 PM
Joined: Mar 2000
Posts: 204
Member
Member
Offline
Joined: Mar 2000
Posts: 204
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 ]


-Never Underestimate The Power Of Stupid People In Large Groups.
#102942 07/27/2001 4:48 PM
Joined: Mar 2001
Posts: 335
Member
Member
Offline
Joined: Mar 2001
Posts: 335
there is no need to require the file...

#102943 07/27/2001 4:49 PM
Joined: Mar 2001
Posts: 335
Member
Member
Offline
Joined: Mar 2001
Posts: 335
and if the file had CGI in it, you would still be printing it out as text, not executing the CGI. (duh)

Sponsored Links
#102944 08/01/2001 5:01 PM
Joined: Mar 2000
Posts: 204
Member
Member
Offline
Joined: Mar 2000
Posts: 204
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 ]


-Never Underestimate The Power Of Stupid People In Large Groups.

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)