CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
I cannot seem to print further data to a text file



Jun 9, 2000, 1:38 AM

Post #1 of 2 (265 views)
I cannot seem to print further data to a text file Can't Post

I have a CGI shopping basket which receives data from input and cookies on my site.

I have been trying to extract the date from the secure server and print it to the order text file. My instructions to print do not work although I get no error messages re syntax.

Here is a sample of the code:

### Write order to file
$ordernum = time;

open(LOCALFILE, ">$filename");

print LOCALFILE "ORDER NO. $ordernum\n\n"; #this works

print LOCALFILE "ORDER DATE:\n"; #this doesn't work
$date=localtime(time); #this doesn't work
print LOCALFILE "$date\n"; #this doesn't work

print LOCALFILE "Qty \tItem \tDescription \tRegistered \tDomaintype \t Price\t Subtotal\n"; #this does work

Why is it not printing the date and my text "ORDER DATE:" can anyone enlighten me as I cannot figure it out!

I have got the date as follows at the beginning of the script:

# Get the Date for Entry
$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);
use Socket;

If anyone can help me unravel this I would be really grateful.


Jun 9, 2000, 8:46 AM

Post #2 of 2 (265 views)
Re: I cannot seem to print further data to a text file [In reply to] Can't Post

Suggestion: set up an environment that lets you run the script from the command line (e.g., by wrapping it inside of another script that sets up environment variables to simulate CGI). Run the script -w

Also, though this may not be your immediate problem, always check error returns from system calls.

open(LOCALFILE, ">$filename") or die "$filename: $!";

[This message has been edited by dws (edited 06-09-2000).]


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives