First of all, you should be careful when using File::Find mixing $File::Find::name with starting out from a relative path for the root directory: File::Find chdirs to the directory the file is in, for the callback, so the proper relative path there is in $_, not in $file::Find::name. Of course, it's a whole other ballgame when you start out from absolute paths.

Anyway: use rel2abs as a class method from File::Spec, or as a function from File::Spec::Functions. Try: either of these:

use File::Find; use File::Spec::Functions qw(rel2abs); $\ = "\n"; find \&print_name, "."; sub print_name{ print rel2abs($_) unless $_ eq "." or $_ eq ".."; }
or
use File::Find; use File::Spec::Functions qw(rel2abs); $\ = "\n"; find \&print_name, rel2abs("."); # or, just for ".": # use Cwd; # find \&print_name, cwd; sub print_name{ print $File::Find::name unless $_ eq "." or $_ eq ".."; }

There's a chance the formatting of the full path is still is not exactly the same as you expect from Windows: there could be a mixture of slashes or backslashes, or the case may not the same as the case for the real physical file/directory names. To fix both these issues, you can use GetLongPathName from Win32, which is a standard library on ActivePerl/Windows.


In reply to Re: How to Get Full Path Name on Win32 System by bart
in thread 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.