Saving Perl Script output to file

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
Spabel
Registered User
Posts: 525
Joined: 11 Apr 2003, 02:00

Saving Perl Script output to file

Post by Spabel »

Lemme paint the picture.

U are hosting a perl script that returns client data. I create a web form to query the script directly and results are given back in html format on the screen.

It all works 100%

Now I dont want it in html format on the screen anymore. I want the results to be saved in a file of any readable type.

Remember I cant change the script because you have it on your server. I need to adjust my query if possible to accept the data returned into a file.

PLEASE HELP!!
All that glitters is not gold,
all those who wander are not lost...

JRR TOLKIEN
vv3bcr3atur3
Registered User
Posts: 304
Joined: 29 Jun 2004, 02:00
Location: Where the mind is

Post by vv3bcr3atur3 »

if you are using Linux you can pipe (|) the command to another command that will save it to the disk. As for windows there could be a way...
"If our ancestors stood still at fire for 10 more years the wheel would have be much rounder by now" - vv3b
francoisvv77
Registered User
Posts: 4
Joined: 14 Mar 2003, 02:00
Location: Bloemfontein

Post by francoisvv77 »

Hi!!
Here is the scripts to write to, and read from a text file in pearl. You can just insert the code into your pearl document:

# write data to a text file
open( FILE, ">>records.txt" );
print( FILE "$firstName, $lastName, $email, $phone\n" );
close( FILE );

# read data from text file
open( FILE, "records.txt" ) or
die( "The database could not be opened." );

print("All records in records.txt",(br),(br));
while ( $line = )
{
chomp( $line );
( $firstName, $lastName, $email, $phone ) = split( ",",
$line );

print($firstName, $lastName, $email, $phone
}
close( FILE );

Hope this helps!!
francoisvv77
Registered User
Posts: 4
Joined: 14 Mar 2003, 02:00
Location: Bloemfontein

Post by francoisvv77 »

HI,

Sorry, I forgot to put something in with the write to file bit: That bit should look like this:

# write data to a text file
open( FILE, ">>records.txt" ) or
die( "The database could not be opened." );
print( FILE "$firstName, $lastName, $email, $phone\n" );
close( FILE );
Post Reply