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

主頁(yè) > 知識(shí)庫(kù) > perl讀寫(xiě)文件代碼實(shí)例

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

熱門(mén)標(biāo)簽:智能機(jī)器人電銷神器 電話機(jī)器人哪里有賣 okcc外呼系統(tǒng)怎么調(diào)速度 熱門(mén)電銷機(jī)器人 惠州龍門(mén)400電話要怎么申請(qǐng) 萬(wàn)利達(dá)百貨商場(chǎng)地圖標(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)簽:綏化 周口 秦皇島 綿陽(yáng) 合肥 百色 淮安 周口

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《perl讀寫(xiě)文件代碼實(shí)例》,本文關(guān)鍵詞  perl,讀寫(xiě),文件,代碼,實(shí)例,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《perl讀寫(xiě)文件代碼實(shí)例》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于perl讀寫(xiě)文件代碼實(shí)例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 三河市| 灌云县| 从化市| 南陵县| 湖南省| 金山区| 左云县| 凭祥市| 彭水| 云南省| 德江县| 湘乡市| 永善县| 登封市| 安远县| 霍山县| 分宜县| 临澧县| 临桂县| 瑞昌市| 桑植县| 石屏县| 张北县| 翁源县| 德钦县| 大方县| 嘉鱼县| 开封县| 香格里拉县| 固阳县| 正镶白旗| 大石桥市| 东丽区| 云和县| 满洲里市| 科尔| 汝南县| 瓦房店市| 湟源县| 伊通| 黄骅市|