Loading ...
Sorry, an error occurred while loading the content.

Sorting Help

Expand Messages
  • Gregory D. Fox
    Hi All, I am trying to sort the following @searchresults array by $current_itemname. I have tried different combinations and still get the same results. The
    Message 1 of 2 , Aug 6 11:14 AM
    • 0 Attachment
      Hi All,

      I am trying to sort the following @searchresults array by $current_itemname.
      I have tried different combinations and still get the same results.

      The code is below. Any help is appreciated.

      TIA...

      ----- CODE ----
      foreach (@inventory){
      ($current_code, $current_category, $current_price, $current_shipping,
      $current_itemname, $current_description, $current_keywords,
      $current_inv_qty, $current_imagename, $current_colors, $current_sizes,
      $current_comments, $current_taxable) = split (/\|/);

      if ($category_search =~ /$current_category/i && $action eq "search by
      $catvar" ){
      if($current_category){
      push @searchresults, $_;
      }
      }
      }


      Gregory D. Fox
      Greg@...
      <><<><<><<><<><<><<><<><<><<><
      Need an eCommerce Solution?
      Visit: http://eCommerceCart.com
      <><<><<><<><<><<><<><<><<><<><
      We also provide web site design and
      hosting. Visit us online at:
      http://LibertyMarketing.com
      <><<><<><<><<><<><<><<><<><<><
    • joach@direct.ca
      I was reading along with this sorting thread and wished to try to resort a data file..... I used one of the examples posted..... but this does not work......
      Message 2 of 2 , Aug 7 8:54 PM
      • 0 Attachment
        I was reading along with this sorting thread and wished to try to resort a data
        file..... I used one of the examples posted..... but this does not work......
        could someone have a look. What I am trying to do is take a file that use
        eight fields and re-order them.... well seven of them

        Tia

        John

        #!/usr/bin/perl -w# for bat file switch - Name change!
        $infile=shift;
        $outfile=shift;

        open (IN, "$infile");
        open (OUT, ">$outfile");

        while (<>) {
        ($field1,$field2,$field3,$field4,$field5,$field6,$field7,$field8) = split(/,/
        $_);
        print "$field1,$field8,$field3,$field4,$field5,$field6,$field7\n";
        }
        close (IN);
        close (OUT);
        exit;
      Your message has been successfully submitted and would be delivered to recipients shortly.