in reply to Pearls (not really) of Perl programming
One of mine, in the early days of learning about DBI...
open INFILE, '<source.txt'; while (<INFILE>) { my $dbh = DBI->connect("dbi:mysql:database=maindb;host=localhost"); my $sth = $dbh->prepare("SELECT * FROM $table WHERE uid=$user"); $sth->execute; print join(',', $sth->fetchrow_array); print "\n"; }
Note the complete lack of error handling, no use of prototypes, and the assumption that only one row would be returned. I also particularly enjoy the two separate print statements. And, I printed to STDOUT (without setting $|) even though I wanted to write to a file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pearls (not really) of Perl programming
by hubb0r (Pilgrim) on Nov 25, 2004 at 07:00 UTC | |
by radiantmatrix (Parson) on Nov 25, 2004 at 13:43 UTC | |
|
Re^2: Pearls (not really) of Perl programming
by ihb (Deacon) on Nov 26, 2004 at 02:17 UTC | |
|
Re^2: Pearls (not really) of Perl programming
by Mr. Muskrat (Canon) on Dec 04, 2004 at 04:05 UTC |