#!/usr/bin/perl require 5.006; use strict; use warnings; $|++; use File::Find (); my %dirs; while( $_ = shift @ARGV ) { next unless -d $_; File::Find::find sub{ -d $File::Find::name and $dirs{$File::Find::name} = undef }, $_; } print $_,$/ for sort keys %dirs;