Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > file::find + absolute path

Reply
Thread Tools

file::find + absolute path

 
 
kielhd
Guest
Posts: n/a
 
      02-26-2004
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
 
Reply With Quote
 
 
 
 
fifo
Guest
Posts: n/a
 
      02-26-2004
At 2004-02-26 06:04 -0800, kielhd wrote:
> 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.
 
Reply With Quote
 
 
 
 
SomeOne
Guest
Posts: n/a
 
      02-26-2004
Hi Microbe
If some one answers that, it will be breast feeding, not spoon feeding
"fifo" <(E-Mail Removed)> wrote in message
news:20040226141822.GB4727@fleece...
> At 2004-02-26 06:04 -0800, kielhd wrote:
> > 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.



 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      02-26-2004
kielhd <(E-Mail Removed)> wrote:

> 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.
...


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Tore Aursand
Guest
Posts: n/a
 
      02-26-2004
On Thu, 26 Feb 2004 06:04:56 -0800, kielhd wrote:
> 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.


--
Tore Aursand <(E-Mail Removed)>
"First, God created idiots. That was just for practice. Then He created
school boards." -- Mark Twain
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does one get an absolute absolute file path? James Byrne Ruby 3 09-14-2010 06:02 PM
How do I convert an absolute path into a relative path Nigel Wilkinson Ruby 2 07-25-2005 07:37 PM
Absolute path in Manifest Class-Path header? bo_kid@yahoo.com Java 10 05-30-2005 01:43 PM
absolute path versus relative path in JSP Matt Java 3 07-08-2004 08:31 PM
Make a relative url path from an absolute path to another one Thomas Guettler Python 3 10-27-2003 04:41 PM



Advertisments