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.
In reply to How to Get Full Path Name on Win32 System by ack
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |