This will work without library on data supplied.May fail on other data best to use jaffa's code if have File::Basename installed.
#!/usr/bin/perl use strict; use warnings; my %seen; while (<DATA>) { m/^(.+\/)(.*)$/; my $path=$1; 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/
In reply to Re^2: Finding deepest directories in a tree structure represented in a flatfile?
by grasshopper!!!
in thread Finding deepest directories in a tree structure represented in a flatfile?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |