You don't need to define the number of elements, just create the array (empty or with the elements you want) and/or push items into it until you are done.
my $file1 = "foo.txt";
my $file2 = "bar.txt";
my @array1 = ($file1, $file2);
# or
my @array2;
print "Enter a file: ";
while (<>) {
chomp;
push @array2, $_;
print "Enter a file: ";
}