> I am currently running a program that creates a
> comma-seperated-value document that has 5 columns.  My question is this:
> Using DBD::CSV is it possible for me to sort the file by column A (a date)
> then by column B (a time) and then by column C (an NT user ID) in
descending
> order?  Here is a snippet I am trying to use:
>
> sub sortlog {
>     $dbh = DBI->connect("DBI:CSV:$logfile");
>     $sth = $dbh->prepare("ORDER BY a [DESC]");
>     $sth->execute();
> }
>
>
> I have absolutely no experience with this module.  Can someone
> please give me some direction on this?  Thank you!


Keith,

Try something like this:

sub sortlog {
    my ( $logdir, $logfile) = @_;
    my $dbh = DBI->connect("DBI:CSV:$logdir");
    my $stmt = "SELECT  a,  b,  c FROM $logfile ORDER BY  a, b, c DESC";
    my $sth = $dbh->prepare($stmt);
    $sth->execute();
    my $ary_ref = $sth->fetchall_arrayref();
    foreach my $row (@$ary_ref) {
        my( $a, $b, $c) = @$row;
        print "$a | $b | $c\n";
    }
)



--
Dave Davisson
[EMAIL PROTECTED]


Reply via email to