开发者

Getting a filename using Perl

开发者 https://www.devze.com 2023-03-23 06:45 出处:网络
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/

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

精彩评论

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

关注公众号