Is there any way to get absolute paths of the files which
are returned by the find command ?
When it doubt, read the documentation. In this case the POD embedded in File::Find, which reads, in part
$File::Find::name contains the complete pathname to the file.
| [reply] [d/l] |
Another option, if you're enamoured of the implicit variables and have a suitably recent version of File::Find, is that you can change the behaviour of $_ to match that of $File::Find::name by using the no_chdir option.
find(
{ wanted => sub { print }, no_chdir => 1, },
@paths
);
--k.
| [reply] [d/l] |
Did you try reading the documentation for File::Find?
$File::Find::dir is the current directory name,
$_ is the current filename within that directory
$File::Find::name is the complete pathname to the file.
--
<http://www.dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] |
Is there any way to get absolute paths of the files which
are returned by the find command ?
Yup, you'll find it in the package variable $File::Find::name. For more info see the File::Find docs.
HTH
_________ broquaint
| [reply] |
Yes there is ... you need to use
$File::Find::fullname
in conjunction with follow => 1. See the docs for
more info, but this should get you started:
perl -MFile::Find -le 'find { wanted => sub {print $File::Find::fullna
+me}, follow => 1}, shift' dir_to_scan
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
| [reply] [d/l] |
I guess you're using $_ which holds the filename.
If you look at the documentation for File::Find you'll see you should really use $File::Find::name
Hope that help's
| [reply] |
Welll, I haven't dealt much with File::Find, but I found this in the docs, maybe it will help you out..
There is a variable $File::Find::fullname which holds the absolute pathname of the file with all symbolic links resolved
This was taken from the docs for File::Find
--
Can't never could do anything, so give me and inch, I'll make it a mile. | [reply] |