in reply to Help with converting Python script to Perl for CSV sort

It looks from the content of your post that you mean CSV rather than CVS. With that in mind you should definitely consider one of the CSV-based modules such as Text::CSV_XS rather than rolling your own.

I am not understanding the sort in the “foreach” loop… is this regex ?

No, this is sort. Perl has extensive, searchable, online documentation. Have a read of the linked page and see if that makes it all clear. Also perhaps the FAQ: How do I sort an array by (anything)?.

  • Comment on Re: Help with converting Python script to Perl for CSV sort

Replies are listed 'Best First'.
Re^2: Help with converting Python script to Perl for CSV sort
by jasonwolf (Sexton) on Jan 31, 2017 at 14:41 UTC
    Thank you for pointing out my mistype in CSV. I have started reading about the Text::CSV
      Python sucks
      use strict; use warnings; use Data::Dumper; use Spreadsheet::Read; use Text::CSV; my $book = ReadData("test.csv"); my @rows = sort { $a->[1] cmp $b->[1] } Spreadsheet::Read::rows($book- +>[1]); open my $fh, ">pl.csv"; my $csv = Text::CSV->new; $csv->eol("\r\n"); $csv->print($fh, $_) for @rows; close $fh;