Fellow Perlish People,
I know this is a problem that's been conquered many times before, but the answer, at present, eludes me. I'm working on a Win2k box with Activestate Perl 5.6. Disk is NTFS format. I need to process all of the files in a directory. The directory name is very long and has spaces in it.
I have followed the recipes in the Cookbook, and they work as long as there are *no* spaces in the path. But when I have a path name like "d:\my documents\my other stuff\*.*" it fails.
Specifically, here is my code:
$thispath = 'd:\my documents\my other stuff\*.*'; print "thispath is [$thispath]\n"; @thisdir = glob($thispath); foreach $thisfile (@thisdir) { print " Found [$thisfile]\n"; }
And the output I get is:
thispath is [d:\my documents\my other stuff\*.*] Found [d:./my] Found [docsmy]
The actual directory has this:
12/11/2000 07:49p <DIR> . 12/11/2000 07:49p <DIR> .. 12/11/2000 07:42p 480 dir.pl 12/11/2000 07:52p 185 dir2.pl 12/11/2000 07:53p 0 out.txt 12/11/2000 11:00a 1,125 populate.pl
However, if I replace the full path with ".\*.*", I get this:
thispath is [.\*.*] Found [.\dir.pl] Found [.\dir2.pl] Found [.\out.txt] Found [.\populate.pl]
I can't seem to find anything on CPAN for this, though I know there must be something somewhere. FYI: I've also tried using opendir, as suggested in another article on this site. Is this a problem with Globbing, or with how the file names are stored in the list?
Any random thoughts? Any specific ones?
Much Thanks.
--Mark

In reply to Long Directory Names by markwild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.