M
MSG
I can't seem to get a grasp on globbing when a directory has a white
space in it.
Here is my code snippet on Win32:
my $dir = 'c:/program files';
my @files = glob "$dir/*";
foreach (@files) { print $_, "\n" };
the output is just:
c:/program
instead of a list of files/directories.
I found two ways to get around the problem:
one is to add a backslash in front of the white space like this
my $dir = 'c:/program\ files';
the other is to double on quotes like this:
my $dir = '"c:/program files"';
But I am wondering what is the escaping/quoting rule with globbing.
One other thing seems odd: It doesn't matter if there is a trailing
slash or not:
both $dir='c:/program\ files' and $dir='c:/program\ files/' work. I
would think that
c:/program files// would mess up the code...
space in it.
Here is my code snippet on Win32:
my $dir = 'c:/program files';
my @files = glob "$dir/*";
foreach (@files) { print $_, "\n" };
the output is just:
c:/program
instead of a list of files/directories.
I found two ways to get around the problem:
one is to add a backslash in front of the white space like this
my $dir = 'c:/program\ files';
the other is to double on quotes like this:
my $dir = '"c:/program files"';
But I am wondering what is the escaping/quoting rule with globbing.
One other thing seems odd: It doesn't matter if there is a trailing
slash or not:
both $dir='c:/program\ files' and $dir='c:/program\ files/' work. I
would think that
c:/program files// would mess up the code...