List all file that match user input perl

Hi, I want to list all file that match user input ( specified shell wildcard) but when I compile it dont list me

#!/usr/bin/perl -w
print "Enter Advance Search Function: ";
chomp ($func = <STDIN>);   
my @files = glob("$func");

foreach my $file (@files) 
    {
    
    print "$file\n";
    
    }
exit 0;

When compile

$ perl test3.pl
$ Enter Advance Search Function: *.txt
$ 

Thank

your code works fine.

 
$ perl test.pl
Enter Advance Search Function: *.txt      
new.txt
old.txt
sp_diff.txt

Make sure you have some .txt files in the current directory (which the perl file is there)