That makes a lot of sense. If I strip out the pipes, tabs, hard returns
etc. going into the database table, do you think that I should be okay not
using the module?
My gut response to my own question is not to assume anything.
Thanks,
Andrew
-----Original Message-----
From: fliptop
To: Hughes, Andrew
Cc: [EMAIL PROTECTED]
Sent: 1/6/2003 6:21 PM
Subject: RE: how to print mysql table to text file backup with perl
On Mon, 6 Jan 2003 at 15:11, Hughes, Andrew opined:
HA:my $filename = "out.txt";
HA:open(OUTFILE,">$filename");
HA: $stmt = qq { select * from 2002brochurecontest };
HA: $sth = $dbh->prepare ($stmt);
HA: $sth->execute ();
HA: $count = 0;
HA: while (my $row = $sth->fetchrow_hashref())
HA: {
HA: print OUTFILE
HA:"$row->{id}|$row->{t}|$row->{f_name}|$row->{l_name}|$row->{w_phone}|$
row->{w
HA:_phone_ext}|$row->{division}|$row->{email}|$row
HA:->{eclub}|$row->{country}|$row->{brochure}|$row->{purchase}\n";
HA: }
HA: $sth->finish();
HA:close(OUTFILE);
that's fine, but what if your data contains pipes? you should look into
one of the csv modules on cpan. here's one i've used in the past with
good success:
http://search.cpan.org/author/JWIED/Text-CSV_XS-0.23/CSV_XS.pm
by default, it uses a comma, but you can specify any character to use as
the delimiter.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]