perl, version 5.8.8
Microsoft Windows XP Pro, SP2

I have a data file containing one or more windows folder paths which I load into an array. When I work through the array and attempt to use the folder path it is not recognized as a valid path. Each line in the data file looks like the following.

C:\HELP\Docs\R2009\sp01\

For this exercise I am using a simple file test to verify the existance of the folder. The actual script uses strict, warnings, and error checking.

my $datafile = "C:\\HELP\\PerlScripts\\Test2.dat"; my (@PATHS); open (DATAFILE,"< $datafile"); while (defined (my $line = <DATAFILE>)) { chomp($line); push (@PATHS,$line); } foreach my $path (@PATHS) { if (-d $path) { print "Found $path \n"; } else { print "DID NOT FIND $path \n"; } }

The previous example code prints "DID NOT FIND C:\HELP\Docs\R2009\sp01\"

The result is the same when the data file entry is C:\\HELP\\Docs\\R2009\\sp01\\

I even went so far as to split the path on "\\" and used join to reconstruct the file path but the results were the same. I assume that I am missing sommething (hopefully something simple) and that one of you fine folks will be able to point that out to me.

Thanks in advance.

In reply to Trouble using a Win32 file path in an array by geo

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.