When you say compare, what do you mean? Do you want to check for exact identity? Same names? Same size? What?#!/usr/bin/perl use strict; use File::Find; find (\&wanted, '.'); sub wanted { next if -d; # skip if it's a directory # $_ is the name of the file # $File::Find::name is the full path and name to the file print "$File::Find::name\n"; }
Here is a way to put the listings into a hash, so you could cycle thru the hash and compare.
#!/usr/bin/perl -w use strict; use Data::Dumper; sub hashdir { my $dir = shift || '.'; opendir my $dh, $dir or die $!; my $tree = {}->{$dir} = {}; while ( my $file = readdir($dh) ) { next if $file =~ m[^\.{1,2}$]; my $path = $dir . '/' . $file; $tree->{$file} = hashdir($path), next if -d $path; push @{ $tree->{'.'} }, $file; } return $tree; } my $tree = hashdir(shift); print Dumper $tree;
In reply to Re: Listing Files
by zentara
in thread Listing Files
by vchavan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |