分类分类
更新时间:2026-11-26 01:08:56作者:zhao
#mode operand create truncate
#read <
#write > yes yes
#append >> yes
Case 1: Throw an exception if you cannot open the file:
use strict;
use warnings;
my $filename = 'data.txt';
open(my $fh, '<:encoding(UTF-8)', $filename)
or die "Could not open file '$filename' with the error $!";
while (my $row = <$fh>) {
chomp $row;
print "$rown";
}
close($fh);
Case 2: Give a warning if you cannot open the file, but keep running:
use strict;
use warnings;
my $filename = 'data.txt';
if (open(my $fh, '<:encoding(UTF-8)', $filename)) {
while (my $row = <$fh>) {
chomp $row;
print "$rown";
}
close($fh);
} else {
warn "Could not open file '$filename' $!";
}
Case 3: Read one file into array
use strict;
use warnings;
my $filename = 'data.txt';
open (FILEIN, "<", $filename)
or die "Could not open file '$filename' with the error $!";
my @FileContents = <FILEIN>;
for my $l (@FileContents){
print "$ln";
}
close FILEIN;
end
相关
AI剪辑图像拍照196.82 MBv21.52026-11-25
下载精灵联萌0.05折版策略游戏13.63 Mv1.0.02026-11-25
下载MilkSU内核管理器实用工具14.29 Mv0.2.62026-11-25
下载百炼仙途角色扮演528.9 Mv10002026-11-25
下载蛊界永生角色扮演407.01 Mv0.4.162026-11-25
下载幻梦无年动作射击276.68 Mv1.1.02026-11-25
下载假人慢打漂泊带土动作射击856.96 Mv0.9.02026-11-25
下载懒人英语学习办公169.94 MBv4.9.62026-11-24
下载天堂奇缘角色扮演23.23 Mv1.0.22026-11-24
下载ZERO浏览器安卓版实用工具70.91 Mv1.0.212026-11-24
下载忍者岚3(Ninja Arashi 3)角色扮演353.82 Mv1.0.22026-11-24
下载越野拉力赛车游戏体育竞技389.01 Mv1.42026-11-24
下载










