校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > perl讀寫文件代碼實例

perl讀寫文件代碼實例

熱門標(biāo)簽:智能機器人電銷神器 電話機器人哪里有賣 okcc外呼系統(tǒng)怎么調(diào)速度 熱門電銷機器人 惠州龍門400電話要怎么申請 萬利達(dá)百貨商場地圖標(biāo)注 河南虛擬外呼系統(tǒng)公司 外呼電信系統(tǒng) 上海企業(yè)外呼系統(tǒng)

#mode operand create truncate
#read  
#write >  yes yes 
#append >> yes

Case 1: Throw an exception if you cannot open the file:

復(fù)制代碼 代碼如下:

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 "$row\n";
}
close($fh);
  

Case 2: Give a warning if you cannot open the file, but keep running:

復(fù)制代碼 代碼如下:

use strict;
use warnings;
 
my $filename = 'data.txt';
if (open(my $fh, ':encoding(UTF-8)', $filename)) {
while (my $row = $fh>) {
chomp $row;
print "$row\n";
}
close($fh);
} else {
warn "Could not open file '$filename' $!";
}
  

Case 3: Read one file into array

復(fù)制代碼 代碼如下:

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 "$l\n";
}
close FILEIN;
  

end

標(biāo)簽:綏化 周口 秦皇島 綿陽 合肥 百色 淮安 周口

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《perl讀寫文件代碼實例》,本文關(guān)鍵詞  perl,讀寫,文件,代碼,實例,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《perl讀寫文件代碼實例》相關(guān)的同類信息!
  • 本頁收集關(guān)于perl讀寫文件代碼實例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 汝南县| 土默特右旗| 祥云县| 南昌县| 静安区| 阿坝| 江源县| 荥阳市| 大冶市| 汶川县| 文登市| 敦煌市| 桐梓县| 无为县| 长治市| 安阳县| 财经| 东丰县| 都兰县| 辽阳县| 安徽省| 罗平县| 临西县| 桐城市| 汤阴县| 密云县| 濉溪县| 杭州市| 虎林市| 灯塔市| 滦南县| 翁牛特旗| 工布江达县| 浦北县| 会昌县| 澄江县| 新和县| 基隆市| 石景山区| 江永县| 巧家县|