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

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

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

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

巨人網(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)民參考!
  • 推薦文章
    主站蜘蛛池模板: 呼和浩特市| 定州市| 布尔津县| 伊宁市| 峨边| 佛山市| 贞丰县| 阳山县| 巨鹿县| 湾仔区| 望谟县| 满洲里市| 新乡县| 隆子县| 抚顺县| 昭通市| 邵武市| 乐安县| 崇阳县| 新邵县| 广德县| 苍南县| 武胜县| 乌鲁木齐市| 南昌县| 乌兰浩特市| 大洼县| 达孜县| 舞阳县| 昭觉县| 屏东县| 包头市| 肃宁县| 卢氏县| 城固县| 红桥区| 望奎县| 长子县| 噶尔县| 蓬莱市| 鄂温|