ANNOUNCE: Text-CSV_XS 0.42

ANNOUNCE: Text-CSV_XS 0.42

am 16.04.2008 15:50:31 von h.m.brand

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

* 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

* 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

Re: ANNOUNCE: Text-CSV_XS 0.42

am 16.04.2008 16:43:33 von 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? Just wondering in case it
may affect any time I might want to use it.

Re: ANNOUNCE: Text-CSV_XS 0.42

am 16.04.2008 17:20:49 von John Bokma

"H.Merijn Brand" 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/

Re: ANNOUNCE: Text-CSV_XS 0.42

am 22.04.2008 18:06:02 von h.m.brand

On Wed, 16 Apr 2008 16:43:33 +0200, Darin McBride
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

Re: ANNOUNCE: Text-CSV_XS 0.42

am 22.04.2008 18:08:28 von h.m.brand

On Wed, 16 Apr 2008 17:20:49 +0200, John Bokma
wrote:

> "H.Merijn Brand" 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.

Re: ANNOUNCE: Text-CSV_XS 0.42

am 22.04.2008 20:36:22 von John Bokma

"H.Merijn Brand" 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/

Re: ANNOUNCE: Text-CSV_XS 0.42

am 23.04.2008 15:01:56 von h.m.brand

On Tue, 22 Apr 2008 20:36:22 +0200, John Bokma
wrote:

> "H.Merijn Brand" 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?

Re: ANNOUNCE: Text-CSV_XS 0.42

am 23.04.2008 18:28:23 von John Bokma

"H.Merijn Brand" wrote:

> On Tue, 22 Apr 2008 20:36:22 +0200, John Bokma
> 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