[Bast-commits] r8681 -
DBIx-Class/0.08/branches/dbicadmin_refactor/script
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sat Feb 13 09:28:05 GMT 2010
Author: ribasushi
Date: 2010-02-13 09:28:04 +0000 (Sat, 13 Feb 2010)
New Revision: 8681
Modified:
DBIx-Class/0.08/branches/dbicadmin_refactor/script/dbicadmin
Log:
Some cleaup, make use of Text::CSV
Modified: DBIx-Class/0.08/branches/dbicadmin_refactor/script/dbicadmin
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin_refactor/script/dbicadmin 2010-02-13 09:27:18 UTC (rev 8680)
+++ DBIx-Class/0.08/branches/dbicadmin_refactor/script/dbicadmin 2010-02-13 09:28:04 UTC (rev 8681)
@@ -43,9 +43,8 @@
)
);
+die "please only use one of --config or --connect-info\n" if ($opts->{config} and $opts->{connect_info});
-die "please only use one of --config or --connect-info" if ($opts->{config} and $opts->{connect_info});
-
# option compatability mangle
if($opts->{connect}) {
$opts->{connect_info} = delete $opts->{connect};
@@ -57,25 +56,21 @@
my $action = $opts->{action};
$action = $opts->{op} if ($action eq 'op');
-my $res = $admin->$action();
-print "going to perform action $action\n";
+print "Performig action $action...\n";
+
+my $res = $admin->$action();
if ($action eq 'select') {
- my $csv_class;
my $format = $opts->{format} || 'tsv';
die('Invalid format') if ($format!~/^tsv|csv$/s);
- $csv_class = 'Text::CSV_XS';
- eval{ require Text::CSV_XS };
- if ($@) {
- $csv_class = 'Text::CSV_PP';
- eval{ require Text::CSV_PP };
- die('The select op requires either the Text::CSV_XS or the Text::CSV_PP module') if ($@);
- }
- my $csv = $csv_class->new({
- sep_char => ( $format eq 'tsv' ? "\t" : ',' ),
- });
+ require Text::CSV;
+
+ my $csv = Text::CSV->new({
+ sep_char => ( $format eq 'tsv' ? "\t" : ',' ),
+ });
+
foreach my $row (@$res) {
$csv->combine( @$row );
print $csv->string()."\n";
More information about the Bast-commits
mailing list