ack has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to Get Full Path Name on Win32 System
by FunkyMonk (Bishop) on Mar 11, 2008 at 21:26 UTC | |
by ack (Deacon) on Mar 12, 2008 at 04:49 UTC | |
|
Re: How to Get Full Path Name on Win32 System
by bart (Canon) on Mar 11, 2008 at 23:05 UTC | |
by ack (Deacon) on Mar 12, 2008 at 05:02 UTC | |
by bart (Canon) on Mar 12, 2008 at 11:55 UTC | |
by krishnoid (Novice) on Aug 28, 2009 at 18:22 UTC | |
|
Re: How to Get Full Path Name on Win32 System
by Corion (Patriarch) on Mar 11, 2008 at 21:37 UTC | |
by ack (Deacon) on Mar 12, 2008 at 04:50 UTC | |
|
Re: How to Get Full Path Name on Win32 System
by Anonymous Monk on Mar 12, 2008 at 03:28 UTC |