writing at a new line to a file?
writing at a new line to a file?
(OP)
Hi,
I'm trying to maintain a log file. Actually I thought it was working fine but there is a little problem:
Each time the script writes to the file it continues on the same line while it should start at a new line.
This is the piece of script that I use:
$download_log = $ENV{'DOCUMENT_ROOT'} . 'download_log.txt';
open (EMAIL_FILE, ">> $download_log") or &error("Could not open data file at line ", __LINE__);
flock EMAIL_FILE, 2 or &error("Could not lock data file at line ", __LINE__);
print EMAIL_FILE $SHORTDATE . " ¦ " . $Name . " ¦ " . $Email . " ¦ " . $occup . " ¦ " . $Country;
close EMAIL_FILE;
flock EMAIL_FILE, 8;
Can anybody tell me what I have to add to the script to start at a new line when it writes to the file?
I guess this is very simple to solve but I don't know how!
Thanks,
raoul
I'm trying to maintain a log file. Actually I thought it was working fine but there is a little problem:
Each time the script writes to the file it continues on the same line while it should start at a new line.
This is the piece of script that I use:
$download_log = $ENV{'DOCUMENT_ROOT'} . 'download_log.txt';
open (EMAIL_FILE, ">> $download_log") or &error("Could not open data file at line ", __LINE__);
flock EMAIL_FILE, 2 or &error("Could not lock data file at line ", __LINE__);
print EMAIL_FILE $SHORTDATE . " ¦ " . $Name . " ¦ " . $Email . " ¦ " . $occup . " ¦ " . $Country;
close EMAIL_FILE;
flock EMAIL_FILE, 8;
Can anybody tell me what I have to add to the script to start at a new line when it writes to the file?
I guess this is very simple to solve but I don't know how!
Thanks,
raoul
RE: writing at a new line to a file?
print EMAIL_FILE qq~$SHORTDATE ¦ $Name ¦ $Email ¦ $occup ¦ $Country\n~;
Sincerely,
Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com
RE: writing at a new line to a file?
Thanks!
RE: writing at a new line to a file?
Sincerely,
Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com
RE: writing at a new line to a file?
Actually the qq~ is what you added, and it does look a bit more sophisticated.
RE: writing at a new line to a file?
For example, you could write this:
print "<input type=\"text\" name=\"$name\" value=\"$value\">";
or this:
print qq~<input type="text" name="$name" value="$value">~;
Isn't that much easier? You can also span multiple lines.
Sincerely,
Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com