in reply to Is there a better way.

my $caseNumber = $ARGV[0]; my $pattern = "(.*?)$caseNumber(.*?)";
The ending (.*?) is pointless there. It's saying "must match ..., followed by zero or more characters". Since there will always be zero or more characters, just leave it off.

And unless case numbers are a fixed length and distinguishable from the surrounding parts of the filename, that's not a good thing to do, since a case number "13" will match a file for case number "113", "130", etc.