- 论坛徽章:
- 1
|
请问能否在一段程序中连续使用glob操作符
glob EXPR
Returns the value of EXPR with filename expansions such as the standard Unix shell /bin/csh would do. This is the internal function implementing the <*.c>; operator, but you can use it directly. If EXPR is omitted, $_ is used. The <*.c>; operator is discussed in more detail in perlop/"I/O Operators".
Beginning with v5.6.0, this operator is implemented using the standard File::Glob extension. See File::Glob for details.
==========================================
File::Glob
Since v5.6.0, Perl's CORE::glob() is implemented in terms of bsd_glob(). Note that they don't share the same prototype--CORE::glob() only accepts a single argument. Due to historical reasons, CORE::glob() will also split its argument on whitespace, treating it as multiple patterns, whereas bsd_glob() considers them as one pattern.
NOTE:
Win32 users should use the real slash. If you really want to use backslashes, consider using Sarathy's File:osGlob, which comes with the standard Perl distribution.
我真的看不出來,連續用glob為什麼會出錯,
至少在Unix,是沒有問題的...M$...沒用過ActivePerl...
或許是Perl for 其他OS的Bug吧..
要不更新Perl到最新版5.8吧..
我的測試script..
#!/usr/bin/perl
$dir = '/apile/perl/ttt';
my @xx = glob "$dir/detail*2001*.bak";
my @yy = glob "$dir/detail*2002*.bak";
for(@xx){
print ;
print "\n";
}
for(@yy){
print ;
print "\n";
}
output:
/apile/perl/ttt/detailXXX20011111XXX.bak
/apile/perl/ttt/detailXXX20011112XXX.bak
/apile/perl/ttt/detailXXX2001XXX.bak
/apile/perl/ttt/detailXXX20021112XXX.bak |
|