ANNOUNCE: Text-CSV_XS 0.42

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->{NAME_lc});
while (my $row = $sth->fetch) {
$csv->print ($fh, $row);
}
close $fh;

2008-04-16 0.42 - H.Merijn Brand <h.m.brand [at] xs4all.nl>

* Generate META.yml myself. I won't use Build.PL
* Array-refs now accept scalars with magic:
$csv->print (*STDOUT, $sth->{NAME_lc});
* More/better examples
* Added t/76_magic.t

2008-04-11 0.41 - H.Merijn Brand <h.m.brand [at] xs4all.nl>

* 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
h.m.brand [ Mi, 16 April 2008 15:50 ] [ ID #1944125 ]

Re: ANNOUNCE: Text-CSV_XS 0.42

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.
Darin McBride [ Mi, 16 April 2008 16:43 ] [ ID #1944126 ]

Re: ANNOUNCE: Text-CSV_XS 0.42

"H.Merijn Brand" <h.m.brand [at] xs4all.nl> wrote:


> $csv->print ($fh, $sth->{NAME_lc});

can one do: ... or die ?

> while (my $row = $sth->fetch) {
> $csv->print ($fh, $row);
> }
> close $fh;

or die ....


--
John

http://johnbokma.com/perl/
John Bokma [ Mi, 16 April 2008 17:20 ] [ ID #1944128 ]

Re: ANNOUNCE: Text-CSV_XS 0.42

On Wed, 16 Apr 2008 16:43:33 +0200, Darin McBride
<dmcbride [at] naboo.to.org.no.spam.for.me> wrote:

> 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
h.m.brand [ Di, 22 April 2008 18:06 ] [ ID #1948056 ]

Re: ANNOUNCE: Text-CSV_XS 0.42

On Wed, 16 Apr 2008 17:20:49 +0200, John Bokma <john [at] castleamber.com>
wrote:

> "H.Merijn Brand" <h.m.brand [at] xs4all.nl> wrote:
>
>
>> $csv->print ($fh, $sth->{NAME_lc});
>
> 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.
h.m.brand [ Di, 22 April 2008 18:08 ] [ ID #1948057 ]

Re: ANNOUNCE: Text-CSV_XS 0.42

"H.Merijn Brand" <h.m.brand [at] xs4all.nl> wrote:


> Of course. But these man pages are to explain Text::CSV_XS' usage, not
> generic
> best practices.

Yet:
open my $fh, ">", "$tbl.csv" or die "$tbl.csv: $!";

^^

YMMV but I would either do it where needed, or not at all. Examples like
yours (IMO) only propagate bad practices. If you want to keep your example
small, you could just put ... after each or.

I mean, why use cruft like:

open my $fh, ">", "$tbl.csv" or die "$tbl.csv: $!";

--
John

http://johnbokma.com/perl/
John Bokma [ Di, 22 April 2008 20:36 ] [ ID #1948058 ]

Re: ANNOUNCE: Text-CSV_XS 0.42

On Tue, 22 Apr 2008 20:36:22 +0200, John Bokma <john [at] castleamber.com>
wrote:

> "H.Merijn Brand" <h.m.brand [at] xs4all.nl> wrote:
>
>> Of course. But these man pages are to explain Text::CSV_XS' usage, not
>> generic best practices.
>
> Yet:
> open my $fh, ">", "$tbl.csv" or die "$tbl.csv: $!";
> ^^
> YMMV but I would either do it where needed, or not at all.

Added for the next release.

> Examples like yours (IMO) only propagate bad practices.

You'll understand that I don't agree here :) Not at all.

> If you want to keep your example small, you could just put ... after
> each or.
>
> I mean, why use cruft like:
>
> open my $fh, ">", "$tbl.csv" or die "$tbl.csv: $!";

cruft?
h.m.brand [ Mi, 23 April 2008 15:01 ] [ ID #1948917 ]

Re: ANNOUNCE: Text-CSV_XS 0.42

"H.Merijn Brand" <h.m.brand [at] xs4all.nl> wrote:

> On Tue, 22 Apr 2008 20:36:22 +0200, John Bokma <john [at] castleamber.com>
> wrote:

[..]

>> I mean, why use cruft like:
>>
>> open my $fh, ">", "$tbl.csv" or die "$tbl.csv: $!";
>
> cruft?

http://www.answers.com/topic/cruft-technology?cat=technology


IMO: either use *proper* error handling everywhere in an example, or make
clear that it's missing.

--
John

http://johnbokma.com/perl
John Bokma [ Mi, 23 April 2008 18:28 ] [ ID #1948919 ]
Perl » comp.lang.perl.modules » ANNOUNCE: Text-CSV_XS 0.42

Vorheriges Thema: Newbie to programming, Net::Divert, Linux-Debian, autoflush error
Nächstes Thema: ANNOUNCE: Text-CSV_XS 0.45