I think the problem is that your pattern is not recognized as one
If you take the match out of your $pattern variable and put it directly
in your grep it should work
opendir(TARGET, ".") or die "Can't open current directory: $!";
my $pattern = '\.pl$';
my @targets= grep {m/$pattern/} readdir TARGET;
print join ("\n", @targets);