|
Posted by H.Merijn Brand on April 16, 2008, 9:50 am
Please log in for more thread options
file: $CPAN/authors/id/H/HM/HMBRAND/Text-CSV_XS-0.42.tgz
size: 86136 bytes
md5: 1cf4491f48965793f1e31fc74159f20f
We can do MAGIC now!
Dumping the content of a database ($dbh) table ($tbl) to CSV:
my $csv = Text::CSV_XS->new ({ binary => 1, eol => $/ });
open my $fh, ">", "$tbl.csv" or die "$tbl.csv: $!";
my $sth = $dbh->prepare ("select * from $tbl");
$sth->execute;
$csv->print ($fh, $sth->);
while (my $row = $sth->fetch) {
$csv->print ($fh, $row);
}
close $fh;
* Generate META.yml myself. I won't use Build.PL
* Array-refs now accept scalars with magic:
$csv->print (*STDOUT, $sth->);
* More/better examples
* Added t/76_magic.t
* error_diag () subclassable
* typo in bind_columns () docs
* examples/csv2xls now uses getline ()
* better test for getline in t/75_hashref.t (makamata)
* document return value of getline () with bind_columns ()
* add perl version prereq to META.yml
|
|
Posted by Darin McBride on April 16, 2008, 10:43 am
Please log in for more thread options
H.Merijn Brand wrote:
> * Generate META.yml myself. I won't use Build.PL
I'm just curious - why won't you use Build.PL? Just wondering in case it
may affect any time I might want to use it.
|
|
Posted by H.Merijn Brand on April 22, 2008, 12:06 pm
Please log in for more thread options On Wed, 16 Apr 2008 16:43:33 +0200, Darin McBride
> H.Merijn Brand wrote:
>
>> * Generate META.yml myself. I won't use Build.PL
>
> I'm just curious - why won't you use Build.PL?
1. Because MakeMaker is good enough for me.
2. Because MakeMaker is clear enough for me (Build hides too much)
3. Build.PL neither does support what I want
4. Build requires me to use lib/, even if I just have a single .pm
5. I love the mantra
# perl Makefile.PL
# make test
# make install UNINST=1
> Just wondering in case it may affect any time I might want to use it.
Use whatever fits your needs best
|
|
Posted by John Bokma on April 16, 2008, 11:20 am
Please log in for more thread options
> $csv->print ($fh, $sth->);
can one do: ... or die ?
> while (my $row = $sth->fetch) {
> $csv->print ($fh, $row);
> }
> close $fh;
or die ....
--
John
http://johnbokma.com/perl/
|
|
Posted by H.Merijn Brand on April 22, 2008, 12:08 pm
Please log in for more thread options wrote:
>
>
>> $csv->print ($fh, $sth->);
>
> can one do: ... or die ?
of course, but do you want to?
>> while (my $row = $sth->fetch) {
>> $csv->print ($fh, $row);
>> }
>> close $fh;
>
> or die ....
Of course. But these man pages are to explain Text::CSV_XS' usage, not
generic
best practices. If I make the examples in the man strict and consice, I
would
have to include
use strict;
use warnings;
use Text::CSV_XS;
before every example. That will just hide the intent of the examples.
|
| Similar Threads | Posted | | ANNOUNCE: PDL-2.4.3 | August 22, 2006, 7:46 am |
| [ANNOUNCE] MultiProcFactory 0.01 | September 20, 2004, 6:29 am |
| ANNOUNCE: WWW::Webrobot 0.50 | September 29, 2004, 10:46 am |
| ANNOUNCE: WWW::Webrobot 0.51 | October 1, 2004, 9:54 am |
| ANNOUNCE: tclperl-3.1 | October 11, 2004, 4:56 am |
| [ANNOUNCE] Net::FTPSSL 0.03 | September 5, 2005, 4:54 pm |
| [ANNOUNCE] POD2::IT 0.09 | September 8, 2005, 11:06 am |
| ANNOUNCE: Teradata::SQL v0.01 | November 17, 2005, 3:23 pm |
| [ANNOUNCE] POD2::IT 0.10 | November 21, 2005, 9:44 am |
| [ANNOUNCE] wxPerl 0.26 | November 23, 2005, 9:41 pm |
|