my $dir = "/path/to"; # or however you initialize my @array = <$dir/*.txt>;