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

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

perl讀寫文件代碼實例

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

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

end

標簽:綏化 周口 秦皇島 綿陽 合肥 百色 淮安 周口

巨人網絡通訊聲明:本文標題《perl讀寫文件代碼實例》,本文關鍵詞  perl,讀寫,文件,代碼,實例,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《perl讀寫文件代碼實例》相關的同類信息!
  • 本頁收集關于perl讀寫文件代碼實例的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 德令哈市| 稻城县| 莆田市| 包头市| 潮州市| 珠海市| 江都市| 黄浦区| 黑河市| 家居| 萍乡市| 娄烦县| 武川县| 西丰县| 崇左市| 长寿区| 白银市| 西和县| 德钦县| 文昌市| 平塘县| 饶河县| 常熟市| 江山市| 敖汉旗| 油尖旺区| 历史| 疏勒县| 延长县| 开化县| 桂阳县| 延边| 萨迦县| 锡林郭勒盟| 廊坊市| 台安县| 桐庐县| 乌审旗| 青龙| 甘孜县| 石阡县|