Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

www.xxxcon, which comes first ob_start or session, wwwxxx/58/2010, xxxxdup, xxxxdup, mailx informatii, should producers of software-based services, such as atms, be held liable for economic injuries suffered when their systems fail?, mysql feiertage, bash netcat eof, 192.168.1.41:8000

Links

XODOX
Impressum

#1: ANNOUNCE: Text-CSV_XS 0.42

Posted on 2008-04-16 15:50:31 by 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 <h.m.brand@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@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

Report this message

#2: Re: ANNOUNCE: Text-CSV_XS 0.42

Posted on 2008-04-16 16:43:33 by 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.

Report this message

#3: Re: ANNOUNCE: Text-CSV_XS 0.42

Posted on 2008-04-16 17:20:49 by John Bokma

"H.Merijn Brand" <h.m.brand@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/

Report this message

#4: Re: ANNOUNCE: Text-CSV_XS 0.42

Posted on 2008-04-22 18:06:02 by h.m.brand

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

Report this message

#5: Re: ANNOUNCE: Text-CSV_XS 0.42

Posted on 2008-04-22 18:08:28 by h.m.brand

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

> "H.Merijn Brand" <h.m.brand@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.

Report this message

#6: Re: ANNOUNCE: Text-CSV_XS 0.42

Posted on 2008-04-22 20:36:22 by John Bokma

"H.Merijn Brand" <h.m.brand@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/

Report this message

#7: Re: ANNOUNCE: Text-CSV_XS 0.42

Posted on 2008-04-23 15:01:56 by h.m.brand

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

> "H.Merijn Brand" <h.m.brand@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?

Report this message

#8: Re: ANNOUNCE: Text-CSV_XS 0.42

Posted on 2008-04-23 18:28:23 by John Bokma

"H.Merijn Brand" <h.m.brand@xs4all.nl> wrote:

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

Report this message