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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New line?

Status
Not open for further replies.

JimJx

Technical User
Joined
Feb 16, 2001
Messages
202
Location
US
Hi all,

I have what I hope is my last problem and a very simpile one.

I am using a flatfile to store some info in the following format:
name|crypt|used

For some reason, I am not getting a new line at the end of the entry so instead of:

name|crypt|used
name2|crypt|used

I get:

name|crypt|usedname2|crypt|used

Can anyone spot the prob? I have a \n at the end the should be getting written.....

Thanks as always,
Jim

Code:
open (INF, ">>DB.txt") or die ("Unable to open the file \'DB\'. $!");
      print INF "$Name\|" . &CryptPassword($Pass) . "\n";
close INF;
 
I'm not sure why it's not printing the newline. You could try printing a list rather than concatinating everything into one string.
Code:
print INF "$Name\|", &CryptPassword($Pass), "\n";
 
Seems to me that it's the newline that should already be at the end of the file that's missing.

Couple of other points: there's no need to escape a single quote in a double quoted string, or a pipe symbol in any string - that's only a special character for regular expressions.
 
The pipe is a special character in a filehandle too. Probably would be rare to have a pipe in a scalar used as a filename but someone might try and inject one in user input for malicous reasons.




------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top