E
enjoylife_95135
Hi,
I am reading a giant chunk of data from a MySQL database, which I'd
like to write into a file so I can process it later.
I'd like to use File::Copy, but it doesn't work. However, I can use
good old print to write to the file though.
Can someone help?
Thanks,
EL
#!/usr/bin/perl
use File::Copy;
$file="/tmp/file.$$";
open(FILE, "+>$file") || die("can't open file: $!");
open(PIPE, "/usr/bin/mysql -e \"use database; select * from filedb
where attrib > 1146567;\" |") || die("can't open pipe: $!");
# This results in a zero byte file being created.
copy(PIPE, FILE);
# But this works well when uncommented.
# foreach my $line (<PIPE>) {
# print FILE "$line";
# }
close (FILE);
close (PIPE);
exit;
I am reading a giant chunk of data from a MySQL database, which I'd
like to write into a file so I can process it later.
I'd like to use File::Copy, but it doesn't work. However, I can use
good old print to write to the file though.
Can someone help?
Thanks,
EL
#!/usr/bin/perl
use File::Copy;
$file="/tmp/file.$$";
open(FILE, "+>$file") || die("can't open file: $!");
open(PIPE, "/usr/bin/mysql -e \"use database; select * from filedb
where attrib > 1146567;\" |") || die("can't open pipe: $!");
# This results in a zero byte file being created.
copy(PIPE, FILE);
# But this works well when uncommented.
# foreach my $line (<PIPE>) {
# print FILE "$line";
# }
close (FILE);
close (PIPE);
exit;