婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識(shí)庫 > perl讀寫文件代碼實(shí)例

perl讀寫文件代碼實(shí)例

熱門標(biāo)簽:智能機(jī)器人電銷神器 電話機(jī)器人哪里有賣 okcc外呼系統(tǒng)怎么調(diào)速度 熱門電銷機(jī)器人 惠州龍門400電話要怎么申請(qǐng) 萬利達(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讀寫文件代碼實(shí)例》,本文關(guān)鍵詞  perl,讀寫,文件,代碼,實(shí)例,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《perl讀寫文件代碼實(shí)例》相關(guān)的同類信息!
  • 本頁收集關(guān)于perl讀寫文件代碼實(shí)例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 青州市| 永城市| 武陟县| 盘山县| 久治县| 始兴县| 蒙城县| 侯马市| 温宿县| 德江县| 建瓯市| 木兰县| 苍溪县| 尚志市| 宝坻区| 舞阳县| 吴堡县| 榆树市| 来宾市| 湘阴县| 大竹县| 普洱| 垦利县| 拉萨市| 清河县| 瓦房店市| 阳江市| 台山市| 竹溪县| 分宜县| 万荣县| 江城| 虎林市| 独山县| 蓬莱市| 肇庆市| 宜川县| 金坛市| 溆浦县| 乐昌市| 利川市|