Welcome, guest! Login
Close

Login to Your Account


  |  » Forgot your password?
Join

Notices

Thread: Perl help.

 
Tools Search
  #1  
Old October 4th, 2002, 02:24 AM
Newbie
Join Date: January 17th, 2005
Posts: 1
Hi. Just a quick question. I'm fairly new to PERL and I just coded a small script I need for my site. Basically what it does is take input from a form and put it into a .txt file in this format;

entry:count
entry2:count2

(entry = what user input, count = how many times that input has been entered). It works fine but the problem is, it writes the file out in order of how the entrys are input.. I'd like it so the most requested entry is at the top, least requested at the bottom, such as..

a:57
b:36
c:31

etc.. can anyone help me with this?
  #2  
Old October 4th, 2002, 07:27 PM
Full Member
Join Date: January 17th, 2005
Posts: 480
A perl guru will probably have a better answer, but I suspect you are going to have open the file, read the entire file into an array, close the file handle, sort the array and then open the file for writing and print the array to the file. In effect you will be opening the file, getting all the data, erasing the file and writing a new file.

makin' money
  #3  
Old October 10th, 2002, 02:41 PM
Newbie
Join Date: January 17th, 2005
Posts: 5
Text files are not they way to go when you need to do sorting. Start using a MySQL Database and your life will be much easier.
Join ABW to remove this sponsored message.
Reply
 

Tools Search
Search:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump

X

Welcome to ABestWeb.com

Create your username to jump into the discussion!

ABestWeb.com is the largest affiliate marketing community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?



Content Relevant URLs by vBSEO ©2011, Crawlability, Inc.