Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 9th, 2001, 09:23 PM
lionheart111 lionheart111 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 0 lionheart111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Wierd File-Reading Problem

I am working on a CGI script for my member site. What I am doing is having it create a seperate file for every member and then hold all of his variables, one to a line, in it. I do this by including a \n after every variable when it is written to the file.

Then, in the display subroutine, I pull all of the variables straight into the hash and display them on the screen. However, the \n seems to be included along with the variable and when it is printed out onto the page, everything on the line after the variable is shifted to the next line. This is creating several problems and I would like to know why this is happening and how to fix it.

I am an not sure why this happens because I thought \n would only appear as a return in the file and then not be included in the variable. Has this happened to anyone else before? Can you help me out?

Thanks,
Leon

Reply With Quote
  #2  
Old September 9th, 2001, 10:25 PM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 77
Send a message via AIM to Hero Zzyzzx
look into chomp(). You need to get rid of those newlines.

This seems like the hard way to deal with tracking member information, creating one file per user. The other thing- you'll be impeding your speed if you have many files (you could (hopefully!) have thousands of members, right?) in a single directory, each open will take longer.

One other wrinkle- simultaneous accesses- If the same file is read/written by the same/different users, you could get corruption or lost data if you aren't very careful about file locking.

You should probably use a rdbms (like mySQL) to track your users. This would take care of your speed, file locking, and potential scalability problems down the road should your site grow.

Good luck!

Reply With Quote
  #3  
Old September 9th, 2001, 10:49 PM
lionheart111 lionheart111 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 0 lionheart111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks alot.
I'll make sure to look into chomp. It seems like just what I need.

What I am doing is severly modifying a free member script I found on the net. It used a standard flat-file database when I got it but that method wasn't able to hold enough information. So I am doing this my way. I would think that creating one file per user would be a better solution than that.

Yes, I do hope that I will have thousands of members someday. Also, I didn't know that the more files in a directory, the longer it takes to access them. Thats interesting, but a solution would be incredably easy. If it comes to that I am sure that I can fix it.

The simultaneous access thing is also actually better in my version. Because if you use a single flat-file then only one member can be editing anything at one time. Here every member can edit their own account and the chances of two people editing the same account is almost nil.

I would use mySQL except that I can't afford it. The host that I am using doesn't offer mySQL support and I can't afford one that can. Also, wouldn't I need to learn a whole new mySQL syntax to use it? Plus, I would have to completely reconfigure my entire program to do it.

Thanks,
Leon

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Wierd File-Reading Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT