Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found