1
glob`功能我想獲得它的名字看起來像所有文件的列表:$res_dir/$line/$fub_name*.istf
問題`在Perl
含義:在目錄$dir
在子目錄$line
與$name
開始,以.istf
結尾的文件。
每個子目錄只包含1個這樣的文件,但是有很多子目錄。我寫了這個:
foreach $line (@arr){
chomp ($line);
$new_istf = glob ("$res_dir/$line/$fub_name*.istf");
do something...
但它並沒有給我所有的文件,但只有一半。當我加入了休耕調試代碼:
if ($new_istf){
print "\tdbug:: $res_dir/$line/$fub_name*.istf:\t'$new_istf'\n";
} else {
print "\tdbug:: $res_dir/$line/$fub_name*.istf:\t''\n";
}
,並輸出結果是:存在
dbug:: RESULTS//791202_0_SA0/ieuni5cts*.istf: 'RESULTS//791202_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791212_0_SA0/ieuni5cts*.istf: ''
dbug:: RESULTS//791241_0_SA0/ieuni5cts*.istf: 'RESULTS//791241_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791248_0_SA0/ieuni5cts*.istf: ''
dbug:: RESULTS//791251_0_SA0/ieuni5cts*.istf: 'RESULTS//791251_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791258_0_SA0/ieuni5cts*.istf: ''
dbug:: RESULTS//791272_0_SA0/ieuni5cts*.istf: 'RESULTS//791272_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791273_0_SA1/ieuni5cts*.istf: ''
dbug:: RESULTS//791301_0_SA0/ieuni5cts*.istf: 'RESULTS//791301_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791333_0_SA0/ieuni5cts*.istf: ''
dbug:: RESULTS//791349_0_SA0/ieuni5cts*.istf: 'RESULTS//791349_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791357_0_SA0/ieuni5cts*.istf: ''
dbug:: RESULTS//791405_0_SA1/ieuni5cts*.istf: 'RESULTS//791405_0_SA1/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791432_0_SA0/ieuni5cts*.istf: ''
dbug:: RESULTS//791434_0_SA0/ieuni5cts*.istf: 'RESULTS//791434_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791459_0_SA0/ieuni5cts*.istf: ''
dbug:: RESULTS//791462_0_SA0/ieuni5cts*.istf: 'RESULTS//791462_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791463_0_SA0/ieuni5cts*.istf: ''
dbug:: RESULTS//791467_0_SA0/ieuni5cts*.istf: 'RESULTS//791467_0_SA0/ieuni5cts.mlc.xxx.x.istf'
dbug:: RESULTS//791471_0_SA1/ieuni5cts*.istf: ''
但所有這些文件。因爲glob
假設像賣解釋工作,我檢查了它,當我做echo RESULTS//791463_0_SA0/ieuni5cts*.istf
(這不是由glob
每個檢測到的其他文件,它提供了正確的文件名。
我也想跑作爲glob的一個襯墊與沒有給出結果的路徑,和它的工作:
perl -e 'print glob("RESULTS//791467_0_SA0/ieuni5cts*.istf"),"\n"'
,它給了正確的結果,以及
哪裏是我的代碼問題