Just use a hash to eliminate duplicates and File::Basename will do the heavy lifting:
use strict; use warnings; use File::Basename qw( fileparse ); my %seen; while (<DATA>) { (undef, my $path, undef) = fileparse( $_ ); print "$path\n" unless $seen{$path}++; } __DATA__ testing123/ foobar/ helloworld/ helloworld/r1/ helloworld/r1/helloworld-5-0.noarch.rpm helloworld/r1/testfile23.txt helloworld/r1/tomcat-7.0.27.rpm helloworld/r2/ helloworld/r2/helloworld-2-0.noarch.rpm helloworld/r2/testfile12.txt helloworld/r2/tomcat-5.0.52.rpm hellotest/
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Finding deepest directories in a tree structure represented in a flatfile?
by jeffa
in thread Finding deepest directories in a tree structure represented in a flatfile?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |