Results 1 to 3 of 3
  1. #1
    Newbie
    Join Date
    January 18th, 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. #2
    Full Member
    Join Date
    January 18th, 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. #3
    Newbie
    Join Date
    January 18th, 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.

+ Reply to Thread

Similar Threads

  1. Allposters Perl
    By reaper in forum Cusimano.com Scripts
    Replies: 5
    Last Post: May 31st, 2005, 12:51 AM
  2. need some perl code...
    By SBTC in forum Programming / Datafeeds / Tools
    Replies: 14
    Last Post: July 30th, 2003, 06:27 AM
  3. Perl Help...
    By eggerda in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: July 22nd, 2003, 05:40 AM
  4. Cron/Perl
    By c4 in forum Programming / Datafeeds / Tools
    Replies: 9
    Last Post: February 4th, 2003, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •