On 10-05-11 04:52 PM, Harry Putnam wrote:
Some selective output first:
[...]
d1 ./dir1/etc/images/gnus/exit-summ.xpm
d2 (1) ./dir2/etc/images/gnus/exit-summ.xpm
d1 ./dir1/etc/images/gnus/reply.xpm
d2 (1) ./dir2/etc/images/mail/reply.xpm
d2 (2) ./dir2/etc/images/gnus/reply.xpm
d1 ./dir1/etc/images/gnus/README
d2 (1) ./dir2/src/m/README
d2 (2) ./dir2/etc/e/README
[...]
d2 (47) ./dir2/doc/lispintro/README
d1 ./dir1/lisp/gnus-util.el
d2 (1) ./dir2/lisp/gnus/gnus-util.el
[...]
If you want the output only in that format, construct your internal
representation to make it easy to process.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
# Make Data::Dumper pretty
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Indent = 1;
# Set maximum depth for Data::Dumper, zero means unlimited
local $Data::Dumper::Maxdepth = 0;
use File::Find;
my %Paths_for = ();
my $Base_dir;
my $Table_format = "%-20s %10s %s\n";
sub wanted {
if( -f ){
push @{ $Paths_for{$_}{$Base_dir} }, $File::Find::name;
}
}
for my $dir ( @ARGV ){
$Base_dir = $dir;
find( \&wanted, $Base_dir );
}
# print '%Paths_for: ', Dumper \%Paths_for;
for my $fname ( sort keys %Paths_for ){
my $count = '';
for my $base_dir ( sort keys %{ $Paths_for{$fname} } ){
for my $path ( @{ $Paths_for{$fname}{$base_dir} } ){
my $enclosed_count = '';
$enclosed_count = "($count)" if $count;
printf $Table_format, $base_dir, $enclosed_count, $path;
$count ++;
}
}
print "\n";
}
__END__
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/