I'd like to note (and obviously promote) the use of new syntax in DBD::CSV available now:

my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { PrintError => 1, RaiseError => 1, f_dir => ".", f_ext => ".csv/r", f_schema => undef, csv_null => 1, csv_auto_diag => 1, });

Using f_ext like that enables you to mix code (.pl-files) and data (.csv-files) in a single directory, and still be able to only see the tables (without the .csv extension).

merijn@tux:~> cat xx.pl #!/pro/bin/perl use strict; use warnings; use DBI; my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { RaiseError => 1, PrintError => 1, f_dir => ".", f_ext => ".csv/r", f_schema => undef, csv_null => 1, csv_auto_diag => 1, }); my $sth = $dbh->prepare ("select b, e from xx order by d, f"); $sth->execute; while (my @row = $sth->fetchrow_array) { print "@row\n"; } merijn@tux:~> cat xx.csv a,b,c,d,e,f 1,2,3,4,5,6 1,3,4,5,3,4 2,5,2,5,2,5 2,4,1,5,8,1 3,5,2,8,1,9 4,5,6,7,8,9 5,1,4,2,5,3 6,2,5,7,1,8 merijn@tux:~> ls -d x* x0 x1 xloadall xx xx.csv xx.pl merijn@tux:~> perl xx.pl 2 5 3 3 5 2 4 8 5 1 5 8 1 5 2 1 merijn@tux:~>

Enjoy, Have FUN! H.Merijn

In reply to Re^2: How do I sort a CSV file on multiple columns? by Tux
in thread How do I sort a CSV file on multiple columns? by mmittiga17

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.