作者LiloHuang (相见不如怀念)
看板Perl
标题Re: [问题] 开启及写入多个档案
时间Sat Apr 25 01:11:19 2009
可以使用下面方式
use FileHandle;
@filename=('a','b','c','d');
my %table;
for $y(0..3) {
for $z(0..3) {
$table{"$filename[$y]$filename[$z]"} = new FileHandle;
$table{"$filename[$y]$filename[$z]"}->open(
">$filename[$y]$filename[$z].txt"
) or die "Could not open file\n";
}
}
for $y(0..3) {
for $z(0..3) {
$table{"$filename[$y]$filename[$z]"}->print("test\n");
}
}
for $y(0..3) {
for $z(0..3) {
$table{"$filename[$y]$filename[$z]"}->close();
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 211.79.63.18