我有以下 perl 代码来执行 sqlite 查询并将结果保存在文本文件中。但我想将结果保存在 Excel 表中。有什么办法可以做到吗?
#!/usr/local/bin/perl -w
use strict;
use DBI;
my $dbfile = 'C:\usage.db3'; # your database file
my $dbh = DBI->connect( # connect to your database, create if needed
"dbi:SQLite:dbname=$dbfile", # DSN: dbi, driver, database file
"", # no user
"", # no password
{ RaiseError => 1 }, # complain if something goes wrong
) or die $DBI::errstr;
#use Data::Dump::Streamer;
my $array1 = $dbh->selectall_arrayref("SELECT USR.id,USR.name, ST.license FROM users USR, status ST, upd_ate UD WHERE UD.upt_id = (select max(p2.upt_id) from upd_ate p2) AND ST.id = USR.id AND ST.upt_id = UD.upt_id ORDER BY ST.license,USR.name");
open FILE, ">btc.txt" or die $!;
foreach my $Ilink (@$array1) {
my ($id, $name, $license) = @$Ilink;
print FILE "$id|$name|$license\n";
}
close FILE;
谢谢