#!/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"; } #### #!/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;