rendered paste body#!/usr/bin/env perl## prints a correct directory tree for given path## usage: foo path d|f|ause warnings;use strict;use File::Find;our(@files, @dirs);my($input, @final, $foo, $bar);find(\&bingo, shift(@ARGV));sub bingo { $_ = $File::Find::name; push(@files, $_) if -f; push(@dirs, $_) if -d;};## now we'v got a separated list of files and dirs@files = sort(@files);@dirs = sort(@dirs);#### playground:while($input = shift(@ARGV)) { if($input eq 'd') { print "$_\n" foreach(@dirs); next; }; if($input eq 'f') { print "$_\n" foreach(@files); next; }; if($input eq 'a') { ## sorting is *very *very slow .. foreach(@dirs) { $foo = $_; push(@final, $foo); foreach(@files) { $bar = $_; $bar =~ s@/.[^/]*$@@; push(@final, $_) if($foo eq $bar); }; }; print "$_\n" foreach(@final); };};exit;