PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > The PowWeb Platform > Perl
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
Old 9-28-09, 05:53 PM   #1
4cbbaker
Registered
 
Join Date: Aug 2009
Location: texas
Posts: 6
Reputation: 0
Writing a record to file; can't get a carriage return to produce separate record line

I am reading and updating records in a simple flat file. I am creating a string to hold the updated record. I write the record with a "\n" following the string. I have tried this on my stand alone server and it works. When I try it on Powweb's server it doesn't recognize the carriage return.
I decided to make a short script that reads the file, updates one record and write out the entire file again. It writes the records that were not changed correctly (one on each line) and the one I update does not have a carriage return. What am I missing? Thanks in advance!

Here is the code:
Code:
open(INF,$fname) or dienice("Can't open $fname: $! \n"); @booths = <INF>; close(INF); $numentries = scalar(@booths); ############ load the BOOTHLIST array that will hold the records for the boothfile by formname ############# foreach $i (@booths) { ($booth, $slot1,$slot2,$slot3,$slot4, $formname) = split(/\|/, $i); $BOOTHLIST{$formname} = $i; } $bname = "facepaint"; ($booth, $slot1,$slot2,$slot3,$slot4, $formname) = split(/\|/, $BOOTHLIST{$bname}); $slot1 = $slot1 - 1; $BOOTHLIST{$bname} = $booth ."|". $slot1 ."|" . $slot2 ."|" . $slot3 . "|". $slot4 . "|" .$formname ."|"; $fname = '>'.$filepath."booth-names-file.fle"; # append the correct directory path; overwrite entire file open (OUTF, $fname) or dienice("Can't open $fname: $! for writing \n"); foreach $key (keys(%BOOTHLIST)) { chomp ($BOOTHLIST{$key}); print OUTF "$BOOTHLIST{$key}"; print OUTF "\n"; } close (OUTF);

Last edited by IanS : 9-28-09 at 07:23 PM. Reason: Added code tags
4cbbaker is offline   Reply With Quote
Old 9-29-09, 03:20 AM   #2
HalfaBee
 
HalfaBee's Avatar
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 7,131
Reputation: 333
If you are outputting html you need to use "<br />\n"
__________________
I don't suffer from laziness, I enjoy every minute!
Edit your php.ini here
http://members.powweb.com/member/cgi...nt/PHPplus.bml
HalfaBee is online now   Reply With Quote
Old 9-29-09, 03:31 PM   #3
Dbrazzell
PowWeb Staff
 
Dbrazzell's Avatar
 
Join Date: Nov 2008
Location: Burlington
Posts: 386
Reputation: 122
How are you viewing the file?

If its in web browser. Check and see what the mime type is listed as.

If its a .txt file our server might serve it up saying its text/plain or maybe it will say text/html

this might cause your web browser to treat the file differently when viewed.
__________________
For Robots only Linky
Dbrazzell is offline   Reply With Quote
Old 9-29-09, 06:02 PM   #4
4cbbaker
Registered
 
Join Date: Aug 2009
Location: texas
Posts: 6
Reputation: 0
I am viewing the file with Notepad. The file extension is .fle. Thanks!
4cbbaker is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 11:28 PM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright © 2000-2007 Jelsoft Enterprises Limited.