I was just reading Beginners guide to File::Find in the Monastary Tutorials (and the pod documentation for File::Find) and was testing some of the examples.

The code is simple and is as follows:

#!/user/bin/perl use File::Find; find(\&print_name, "."); exit(0); sub print_name{ print "[$File::Find::dir] [$File::Find::name]\n" unless(($_ eq ".") or ($_ eq "..")) }

The output is:

[.] [.] [./DAYS2MDH.M] [.] [./INVJDAY.M] [.] [./JDAY.M] [.] [./mdy2doy.m] [.] [./MyBigTest.pl] [.] [./MyBigTest.vpd] [.] [./MyLearn04.pl]

According to the Tutorial and the comments, this should work on a Win32 system (which is what I was testing this on). But rather than giving me the 'full path', it gives me '.'.

I seem to recall that on Win32 systems there can be problems with getting full path names; but the Tutorial says otherwise.

How does one get the 'full path' name rather than the '.'? Or just point me in the right direction to address this issue since I can't remember where I saw/read the caveats about path names re: Win32 system?

UPDATE: Thanks everyone. I went with the full directory approach in the find() and it works just fine. In scouting around CPAN I also found File::Find::Wanted which is a real nice, simple wrapper around File::Find and is a bit more intuitive than File::Find. Though it's not clear how one gets to the variables $File::Find::name, $File::Find::dir...which are really nifty in the File::Find module.

ack Albuquerque, NM

In reply to How to Get Full Path Name on Win32 System by ack

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.