Re: How to ignore spaces in directory names?



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

.



Relevant Pages

  • ANN: vile 9.5
    ... + syntax filters can now be dynamically loaded. ... repeated '_' selects the first buffer shown. ... + modify name-completion to allow completion of filenames containing ... command rather than having it erased. ...
    (comp.editors)
  • Re: Cannot find -lf2c compilation error
    ... However, when I run the command 'make', I get the ... You don't have to modify anything. ... ld terminated with signal 11 [Segmentation fault] ... Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines ...
    (Fedora)
  • Re: debugger internals
    ... Windows has special compact debugging API that includes, among others, functions GetThreadContext and SetThreadContext. ... ReadProcessMemory and WriteProcessMemory allow you to set INT3 breakpoints. ... Of course, you must read original first byte of the command before writing INT3, otherwise you will be unable to restore the command after break. ... You may, for example, disable write access to data memory and get exception on write to the protected memory block. ...
    (comp.lang.asm.x86)
  • Re: Changing NSINTERADDR dynamically - URGENT
    ... does is point you to the MODIFY command in the IP System Administrator?s ... John has a locally created RESOLVER started task procedure so he can start it ... You are using only default values for the resolver configuration file so no ...
    (bit.listserv.ibm-main)
  • Re: gdb stepping into boring stuff
    ... The "step" command doesn't step into functions that have no debugging ... hash table within the gdb convenience variables (which I think is ... with the $known_uninteresting_pc being kept as an array local to the ...
    (comp.os.linux.development.apps)