Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Finding deepest directories in a tree structure represented in a flatfile?

by u65 (Chaplain)
on Dec 05, 2015 at 00:18 UTC ( #1149431=note: print w/replies, xml ) Need Help??


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?

Unless the OP made a mistake, he did not include helloworld/ in his definition of a terminal directory, thus your solution doesn't quite work, but I'll bet you can tweak it so it will work!

  • Comment on Re^2: Finding deepest directories in a tree structure represented in a flatfile?
  • Download Code

Replies are listed 'Best First'.
Re^3: Finding deepest directories in a tree structure represented in a flatfile? (mapAdj)
by Anonymous Monk on Dec 05, 2015 at 01:27 UTC

    Unless the OP made a mistake, he did not include helloworld/ in his definition of a terminal directory, thus your solution doesn't quite work, but I'll bet you can tweak it so it will work!

    i don't like your phrasing , to which i say, can't you do it?

    yeah, none of the solutions filter out the parents of terminals, so with help from Re^4: Want for a name? (between)

    #!/usr/bin/perl -- use strict; use warnings; sub mapAdj(&$@) { use vars qw/ $a $b $c $d $e $f $g $h $i $j /; local( $a, $b, $c, $d, $e, $f, $g, $h, $i, $j ); my( $code, $n ) = ( shift, shift ); map $code->( ($a, $b, $c, $d, $e, $f, $g, $h, $i, $j ) = @_[ $_-$n .. $_ ] ), --$n .. $#_; } sub subsumes { return 0 == index $_[1], $_[0]; } my $termies = " a/ a/b/ a/b/t/ a/b/t/f a/c/ a/c/d/ a/c/d/t/ a/c/d/t/f t/ "; open my($fh),'<',\$termies; my @terminals; while(<$fh>){ chomp; push @terminals, $_ if m{/\s*$}sm; } @terminals = mapAdj { subsumes($a,$b) ? ( ) : ( $a ) } 2, (sort @termi +nals), ''; print "$_\n" for @terminals; __END__ a/b/t/ a/c/d/t/ t/

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1149431]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2021-05-14 18:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?