首页 > 应用开发 > IT综合 > perl 中glob函数的使用
Try out following example: Here glob will retun all the files which begin with "perl_g"
#!/usr/bin/perl[@more@] Syntax
(@file_list) = glob "perl_g*";
print "Returned list of file @file_listn";
glob EXPR glob |
Returns a list of files matching EXPR as they would be expanded by the standard Bourne shell. If the EXPR does not specify a path, uses the current directory. If EXPR is omitted, the value of $_ is used.
From Perl 5.6 on, expansion is done internally, rather than using an external script. Expansion follows the csh (and any derivatives, including tcsh and bash) style of expansion, which translates as the following:
In scalar context undef on error otherwise First file in the list of expanded names
In list context Empty list on error otherwise List of expanded file names.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16723161/viewspace-1016238/ ,如需转载,请注明出处,否则将追究法律责任。