Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting full path from Find::File 1

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
0
0
GB
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
 
Hi

They mention [tt]$File::Find::dir[/tt], which works for me like this :
Perl:
[b]sub[/b] search_all_folder [teal]{[/teal]
    [b]print[/b] [i][green]"Just found file '$_' in directory '$File::Find::dir'\n"[/green][/i][teal];[/teal]
[teal]}[/teal]


Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top