Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing at a new line to a file?

Status
Not open for further replies.

rtb1

IS-IT--Management
Jul 17, 2000
73
ES
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
 
add a newline(\n)!

print EMAIL_FILE qq~$SHORTDATE ¦ $Name ¦ $Email ¦ $occup | $Country\n~;
 
I tried this but without the ~ at the end which gave an internal error.

Thanks!
 
If you start your string with qq~ then you have to end it with ~; Did the newline help?
 
Yes it did,thanks again!

Actually the qq~ is what you added, and it does look a bit more sophisticated.
 
Using qq~~; means that you don't have to escape the quotes.

For example, you could write this:

print &quot;<input type=\&quot;text\&quot; name=\&quot;$name\&quot; value=\&quot;$value\&quot;>&quot;;

or this:

print qq~<input type=&quot;text&quot; name=&quot;$name&quot; value=&quot;$value&quot;>~;

Isn't that much easier? You can also span multiple lines.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top