file::find + absolute path

K

kielhd

Hi NG,
I am looking into this problem for a while and can't find a solution.
I need the ***absolute path*** of the files. The following script
gives me the filenames, but not the path:

#!C:\Perl\bin\perl.exe -w
use File::Find;
$dir = "E:\\";
find(\&wanted, $dir);

foreach (@files)
{
print ("---> $_\n");
}

sub wanted { if ( $_ =~ /\.mp3$/ ) { push (@files, $_); } }

exit;

What do I have to do to get the corresponding pathname?

Any hints are appreciated!

Best regards, Henning
 
F

fifo

Hi NG,
I am looking into this problem for a while and can't find a solution.
I need the ***absolute path*** of the files. The following script
gives me the filenames, but not the path:

#!C:\Perl\bin\perl.exe -w
use File::Find;
$dir = "E:\\";
find(\&wanted, $dir);

foreach (@files)
{
print ("---> $_\n");
}

sub wanted { if ( $_ =~ /\.mp3$/ ) { push (@files, $_); } }

exit;

What do I have to do to get the corresponding pathname?

perldoc File::Find

The section on the wanted function should tell you what you need to
know.
 
T

Tad McClellan

kielhd said:
I am looking into this problem for a while and can't find a solution.


Where have you been looking?

Did you look at the documentation for the functions that you are using?

That would seem like the very first place to look...

use File::Find;

sub wanted { if ( $_ =~ /\.mp3$/ ) { push (@files, $_); } }
What do I have to do to get the corresponding pathname?


Access the variable that your function's docs say will contain
the corresponding pathname.

Any hints are appreciated!


Read the documentation for the functions that you use.

perldoc File::Find

...
$File::Find::name is the complete pathname to the file.
...
 
T

Tore Aursand

I am looking into this problem for a while and can't find a solution. I
need the ***absolute path*** of the files. The following script gives me
the filenames, but not the path:
[...]

That's because you only care about the filename in your script. Read the
documentation - 'perldoc File::Find' - for information on how to use that
excellent module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top