From: short <> Date: Fri, 9 Apr 2004 16:02:06 +0000 (+0000) Subject: Print base of each directory subtree specified in the unsorted input list. X-Git-Tag: bp_liverpm~25 X-Git-Url: http://git.jankratochvil.net/?p=nethome.git;a=commitdiff_plain;h=0bde3961e9c31ff55bc932748002e600a8154805 Print base of each directory subtree specified in the unsorted input list. --- diff --git a/bin/dirlistbases b/bin/dirlistbases new file mode 100755 index 0000000..d89c5d2 --- /dev/null +++ b/bin/dirlistbases @@ -0,0 +1,36 @@ +#! /usr/bin/perl +use strict; +use warnings; + +my $tree; +LINE: while (<>) { + chomp; + my $base=\$tree; + warn($_),next if !s#^/##; + warn($_),next if m#//#; + warn($_),next if m#/$#; + for (split qr#/#) { + next LINE if ${$base}->{""}; + $base=\(${$base}->{$_}); + } + ${$base}->{""}=1; + } +#use Data::Dumper; +#print Dumper $tree; + +sub out($$); +sub out($$) +{ +my($base,$where)=@_; + + if ($base->{""}) { + print $where."\n"; + return; + } + for (sort keys(%$base)) { + next if $_ eq ""; + out($base->{$_},"$where/$_"); + } +} + +out($tree,"");