开发者

Getting a filename using Perl

There is a file named *.iso, where * is any string (dot, numbers, alphabets, spl characters).

*.iso is located at /dm2/www/html/isos开发者_JS百科/preFCS5.3/

I want to get this filename into $filename. I know it's very simple. How can I do this in Perl?


Use File::Util

use strict;
use warnings;
use File::Util;

my $file_util = File::Util->new;
my $base = '/dm2/www/html/isos/preFCS5.3/';
my @isos = $file_util->list_dir(
    $base,
    '--recurse',
    '--files-only',
    '--pattern=\.iso$'
);


my($filename) = glob('/dm2/www/html/isos/preFCS5.3/*.iso');

For more info: http://perldoc.perl.org/functions/glob.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜