in reply to list two paths files into one array

As a preliminary note, I would say that your code doesn't compile. Even the very first line doesn't compile.

Otherwise, what you can do is to store the entries of the first dir into an array, and then add the entries of the second one to this array. Something like this:

my $Dir1 = "d:/xxxxxx"; my $Dir2 = "d:/yyyyyy"; my @files = glob ("$Dir1/*"); for my $file (glob "$Dir2/*" ) { push @files, $file; } for my $file (@file) { print $file, "\n" }
Of course, this can be made somewhat shorter:
my $Dir1 = "d:/xxxxxx"; my $Dir2 = "d:/yyyyyy"; my @files = glob ("$Dir1/*"); push @files, $_ for glob "$Dir2/*"; print $_, "\n" for @file;

Replies are listed 'Best First'.
Re^2: list two paths files into one array
by pryrt (Abbot) on Nov 14, 2017 at 00:54 UTC

    push accepts a list as the second "argument" (and provides list context in that position), so there's no need for the for loop around the second glob: push @files, glob "$Dir2/*"; is sufficient. Of course, now we've given the spoiler for my step #3... oh, well.

      Yes, this is right: there is no real need for the for loop in this case. I thought that it was still better to show the process in an explicit loop since the OP is really a beginner. TIMTOWTDI, there are in fact many ways to do it.

      Sorry for "spoiling" your answer, I did not think about that, but just thought that the OP deserved a simple example solution.