my @plf_files = {"files.plf","orphans.plf"};creates a single element array containing a reference to a hash, because you used { } (called a 'composer'). You probably meant:
my @plf_files = ('files.plf','orphans.plf');
Your subroutine tests the same thing several times, try this:
sub recursion
{
my $plf = shift;
open my $fh, '<', $plf or die "could not open '$plf' $!";
foreach (my $line = <$fh>){
if($line =~ /(\w+\.plf)$/)
{
$match_plf_name = $1;
next if $match_plf_name eq $plf;
push @recursive_plfs ,$match_plf_name;
recursion($match_plf_name);
}
}
}
You will notice that I don't use $DATA for filehandle name. This is because there is a reserved filehandle called DATA, so $DATA would be confusing. You will also notice that there is not a
grep in sight. The capturing parentheses group is saved into $1.
Finally, notice also the 'next' statement as an insurance against infinite recursion.