in reply to Re: Finding deepest directories in a tree structure represented in a flatfile?
in thread Finding deepest directories in a tree structure represented in a flatfile?
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/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Finding deepest directories in a tree structure represented in a flatfile?
by RonW (Parson) on Dec 05, 2015 at 01:34 UTC |