From: Peter Rabbitson Date: Sat, 13 Feb 2010 09:28:04 +0000 (+0000) Subject: Some cleaup, make use of Text::CSV X-Git-Tag: v0.08119~9^2~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ad81fe7d16ee1a96bcd2c69b674e2cd1ead683cd;p=dbsrgits%2FDBIx-Class.git Some cleaup, make use of Text::CSV --- diff --git a/script/dbicadmin b/script/dbicadmin index 35a600a..c50c50b 100755 --- a/script/dbicadmin +++ b/script/dbicadmin @@ -43,8 +43,7 @@ my ($opts, $usage) = describe_options( ) ); - -die "please only use one of --config or --connect-info" if ($opts->{config} and $opts->{connect_info}); +die "please only use one of --config or --connect-info\n" if ($opts->{config} and $opts->{connect_info}); # option compatability mangle if($opts->{connect}) { @@ -57,25 +56,21 @@ my $admin = DBIx::Class::Admin->new( %$opts ); 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";