wildcard help!!

i have got heaps of files (.pdf, .txt and .doc) files in one folder, i am making a program in PERL that helps me find the files i want easier using shell wildcard,

something like this!!

print "Enter a pattern: (must be in [])";
$input = <STDIN>;

if (The input is in [] and valid wildcard pattern)
{
list all the files with the inputted pattern;
}

else
{
print "invalid input";
}

your help will be appreciated!!

$ cat test.pl
print "Enter a pattern: ";
$ext = <STDIN>;
@list = <*.$ext>;
foreach (@list)
{
    print $_;
}
1 Like

thanks itkamaraj for the reply,

but it doesn't list anything, even thought it exists,, like *.txt (i am a beginner :D)

$ perl test.pl
Enter a pattern: txt
A.txt
B.txt
b.txt
Characters.txt
CPU_VALUE.txt
empty.txt
FC1-original-input.txt
FC1.txt
FC2-original-input.txt
FC2.txt
input.txt
replace.txt
swap.txt
test.txt
xyz.txt

working fine..

1 Like