tags:

views:

69

answers:

2

From here

#!/usr/bin/perl
my @arr = ('/usr/test/test-[\d.*].*.con');

How to support the searching file based on regular expression

+4  A: 

If I understand your question, here's one way to do it: use glob to find all files in the directory and grep to filter them.

my $dir = '/usr/test';
my @files = grep { /REGEX_HERE/ } glob("$dir/*");
FM
i cant defind the dir because i am getting full string . so how can i change this part
Tree
@Tree Sorry, I'm not understanding your question. Perhaps you can clarify.
FM
A: 

you can use File::Find for doing exactly this.

use File::Find;

my @files = ();
find( sub {/test-[\d.*].*.con/ && push @files, $File::Find::name}, '/usr/test' );

print foreach (@files);
dsm