Hi, I have to sort a file depending on a particular value, the problem is that the value can be number,string or alphanumeric. So which comparison opertor will work on all these? This is the script :
use strict; my $column=3; my @F; my @sort_col; my @lines; my $file=$ARGV[0]; while(<>) { #print "Input line " .$_; @F=split(/\|/,$_); print "Array elesems $F[3]\n"; push @sort_col, $F[$column]; push @lines, "$_"; } print @lines[sort{ $sort_col[$a] lt $sort_col[$b] } 0..$#sort_col] ;
And the input file :
D|0|95465tan|2|4|4|14028.77|0.00|BF2-002|22/09/2009|07/01/2009|06/09/2 +009|45544564| D|0|954564545|1|4|abar_BF4|4|3913.17|0.00|accabar_BF4-003|22/09/2009|0 +7/02/2009|06/09/2009|10254754| D|0|a454654|1|4|ar_BF4|4|3913.17|0.00|acctrabar_BF4-003|22/09/2009|07/ +02/2009|06/09/2009|11122323| D|0|Chking|1|4|arabar_BF4|4|3913.17|0.00|acarabar_BF4-003|22/09/2009|0 +7/02/2009|06/09/2009|11122323|
Thanks

In reply to Comparison of alphanumeric strings by Anonymous Monk

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.