1. The while(<FILE>) { reads the file one line at a time so there is no need to split the $_ then. So the split to @all is superfluous.
  2. You should use chomp() not chop() if you want to remove the newline character. The thing is that the chop() removed one character, no matter what it is. So if the last line in the file doesn't end with a newline character, you will remove the last character of the line!
  3. You use a heluvalot of related variables there, maybe you should rather stick all this data into a hash. You will actually need to do that to be able to sort the items.
    while (<FILE>){ chomp; my %store;@store{Id Name Username Password ...} = split / /; $store{km} = ... push @stores, \%store; } foreach (sort {$a->{km} <=> $b->{km}} @stores) { print "...." }
  4. You stick the values of those variables into the URL without any escaping whatsoever! What if the data contain something that's special in URLs? Spaces, &s, #s, %, ... You should always make sure you escape all the data you print in whatever way necessary for the place you stick them at! (In this case have a look at CGI::Enurl for example.)

Jenda
Enoch was right!
Enjoy the last years of Rome.


In reply to Re: Sort output by Jenda
in thread Sort output by pglinx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.