on ./books.csv which contains#!/usr/bin/env perl use Data::Dumper; use DBI; use Try::Tiny; use strict; use warnings; try { my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_dir => "./", f_ext => ".csv/r", f_lock => 2, csv_eol => "\r\n", csv_sep_char => "|", RaiseError => 1, PrintError => 1, FetchHashKeyName => "NAME_lc", }) or die $DBI::errstr; # Sorting by author my $sth=$dbh->prepare(<<"__SQL__"); select * from books order by author __SQL__ $sth->execute(); my $field_aref=$sth->{NAME_lc}; warn Data::Dumper->Dump([\$field_aref],[qw(*field_aref)]),' '; while (my $value_aref=$sth->fetchrow_arrayref()) { warn Data::Dumper->Dump([\$value_aref],[qw(*value_aref)]),' '; }; } catch { Carp::confess $!; };
results intitle1|title2|pages|author Perl Best Practices|hound|a few|Damian Conway Learning Perl|llama|thin|Randal Schwartz Programming Perl|camel|many|Larry Wall
$field_aref = \[ # fields 'title1', 'title2', 'pages', 'author' ]; at data.plx line 28. $value_aref = \[ # first when sorted by aut +hor 'Perl Best Practices', 'hound dog', 'a few', 'Damian Conway' ]; at data.plx line 30. $value_aref = \[ 'Programming Perl', 'camel', 'many', 'Larry Wall' ]; at data.plx line 30. $value_aref = \[ 'Learning Perl', 'llama', 'thin', 'Randal Schwartz' ]; at data.plx line 30.
In reply to Re: Sorting Text File for HTML Output
by clueless newbie
in thread Sorting Text File for HTML Output
by michael.kitchen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |