Re: How to ignore spaces in directory names?
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 13 Jul 2006 13:23:13 -0700
Nishi Bhonsle wrote:
In writing a perl script to read the contents of a directory on a windows
system, i noticed that there are some directory names have spaces in them.
How can I modify the line below so it would ignore the spaces in the
directory name and still process it ?
opendir DIR, $path or die "Can't open $path: $!";
P.S In the above line, $path is the directory path passed to the program as
a command line argument.
You need to work on debugging your problems, rather than making broad
sweeping assumptions. You are assuming that the problem is that
opendir is failing to open whatever directory is named by $path. If
you print $path out, though, you'll see that $path does not contain the
name of your directory at all. That should have been one of your first
debugging steps.
Pare your program down until you find the root cause of the problem.
In this case, that's going to be how Windows passes arguments to your
program. That has nothing to do with Perl, because the problem would
have been the same regardless of what language your program was written
in.
Since I'm feeling generous, however - surround the pathname in double
quotes on the command line:
C:\>perl myprog.pl C:\Document and Settings\Paul
Should become
C:\>perl myprog.pl "C:\Document and Settings\Paul"
Paul Lalli
.
- References:
- How to ignore spaces in directory names?
- From: Nishi Bhonsle
- How to ignore spaces in directory names?
- Prev by Date: Re: Regexp help please
- Next by Date: Re: Regexp help please
- Previous by thread: RE: How to ignore spaces in directory names?
- Next by thread: How to get the OS local/default drive using perl?
- Index(es):
Relevant Pages
|