×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

writing at a new line to a file?

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

RE: writing at a new line to a file?

add a newline(\n)!

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?

(OP)
I tried this but without the ~ at the end which gave an internal error.

Thanks!

RE: writing at a new line to a file?

If you start your string with qq~ then you have to end it with ~;  Did the newline help?

Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com

RE: writing at a new line to a file?

(OP)
Yes it did,thanks again!

Actually the qq~ is what you added, and it does look a bit more sophisticated.

RE: writing at a new line to a file?

Using qq~~; means that you don't have to escape the quotes.

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close