M
Mr. Land
Hello.
I've read what I could find on filename globbing and can't seem to get
an answer for the following:
I have directory containing files like:
File One.red
File One.blue
File One.green3
File One.Green4
File One.Gray4
SecondFile.red
SecondFile.blue
SecondFile.green4
I have built an array containing the "basenames" (everything up to but
not including the last ".") of
all files in the directory. For my example above, my array would
contain 2 elements:
"File One"
"SecondFile"
Now, for each such array entry I am trying to get an array of
filenames which match a certain pattern,
that pattern being based on the entry. For example to get a list of
all files having the basename
and having an extension that begins with either "g" or "G" and ends in
"4":
foreach $basename (@TheArray) {
@fileList = <$basename*[gG]*4>;
This worked as shown for "SecondFile" but failed with "File One" due
to the embedded space. I tried
various forms of quoting, such as:
@fileList = <'$basename'*[gG]*4>;
@fileList = <'$basename*[gG]*4'>;
@fileList = <"$basename*[gG]*4">;
but none of these seem to handle BOTH cases (with and without embedded
spaces in the basename).
Is there at least one way to do this and what would that look like?
Thanks.
I've read what I could find on filename globbing and can't seem to get
an answer for the following:
I have directory containing files like:
File One.red
File One.blue
File One.green3
File One.Green4
File One.Gray4
SecondFile.red
SecondFile.blue
SecondFile.green4
I have built an array containing the "basenames" (everything up to but
not including the last ".") of
all files in the directory. For my example above, my array would
contain 2 elements:
"File One"
"SecondFile"
Now, for each such array entry I am trying to get an array of
filenames which match a certain pattern,
that pattern being based on the entry. For example to get a list of
all files having the basename
and having an extension that begins with either "g" or "G" and ends in
"4":
foreach $basename (@TheArray) {
@fileList = <$basename*[gG]*4>;
This worked as shown for "SecondFile" but failed with "File One" due
to the embedded space. I tried
various forms of quoting, such as:
@fileList = <'$basename'*[gG]*4>;
@fileList = <'$basename*[gG]*4'>;
@fileList = <"$basename*[gG]*4">;
but none of these seem to handle BOTH cases (with and without embedded
spaces in the basename).
Is there at least one way to do this and what would that look like?
Thanks.