Skip to content

Instantly share code, notes, and snippets.

@reneeb
Created October 25, 2013 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reneeb/7159200 to your computer and use it in GitHub Desktop.
Save reneeb/7159200 to your computer and use it in GitHub Desktop.
my @data;
my $sth = $dbh->prepare( $sql ) or die $dbh->errstr;
$sth->execute;
while ( my @row = $sth->fetchrow_array ) {
push @data, [@row];
}
open my $fh, '>', $flat_file or die $!;
print $fh @{$_},"\n" for @data;
close $fh;
# now better:
open my $fh, '>', $flat_file or die $!;
my $sth = $dbh->prepare( $sql ) or die $dbh->errstr;
$sth->execute;
while ( my @row = $sth->fetchrow_array ) {
print $fh @row,"\n";
}
close $fh;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment