×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Getting full path from Find::File

Getting full path from Find::File

Getting full path from Find::File

(OP)

This is a simplified version of a script to list all the files on a webserver, it works ok but it would be easier if I could print the full path of each file rather than just the file's name.
I have read through the Docs of File::Find and they don't appear to cover what I require.

Is it possible to get the path for each file or am I barking up the wrong tree?
I could write a long winded script to perform this task but you guys seem to manage tasks like this with a couple of lines of code.

CODE

use File::Find qw(find);

my $path = abs_path $ARGV[0];
find( \&search_all_folder, $path );

sub search_all_folder {
	chomp $_;
	return if $_ eq '.' or $_ eq '..';
	read_files($_) if (-f);
}

sub read_files {
	my($part,@AllData);
	my ($filename) = @_;
	open (LOG, "<$filename") || print "No $filename";
	my @AllData = <LOG>;
	close (LOG);
	foreach $part (@AllData){
		print "<span style='color:#ff0000;'>$filename</span><br>$part<br><br>";
	}
} 

Keith
www.studiosoft.co.uk

RE: Getting full path from Find::File

Hi

They mention $File::Find::dir, which works for me like this :

CODE --> Perl

sub search_all_folder {
    print "Just found file '$_' in directory '$File::Find::dir'\n";
} 

Feherke.
feherke.ga

RE: Getting full path from Find::File

(OP)
Thanks Feherke
I hadn't realised you could call that after the event - I thought it was for specifying a specific dir to search.

Keith
www.studiosoft.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close