use strict; use warnings; use Smart::Comments; use List::MoreUtils qw(any); use File::Spec; my @RE_IGNORED = map { s/\./\\./g; s/\+/\\+/g; s/\?/.?/g; s/\*/.*?/g; qr/^$_$/; } grep {length} map {tr/\n//d; $_} ; main(); sub main { my @current = find($ENV{HOME}, '.', sub {$_[0] =~ m/^\./}); foreach (@current) { print "$_\n"; } } sub find { my $base = shift; my $dir = shift || '.'; my $sel = shift || sub {1}; my $dirpath = File::Spec->catfile($base, $dir); opendir my $dh, $dirpath or die "opendir: $dirpath: $!"; my @d; while (my $name = readdir $dh) { next if $name =~ /^\.\.?$/; next if !$sel->($name); my $abs = File::Spec->rel2abs($name, $dirpath); my $rel = File::Spec->abs2rel($abs, $base); next if any { $rel =~ m/$_/ } @RE_IGNORED; next if !-f $abs; if (-d $abs) { push @d, find($base, $rel); } else { push @d, $rel; } } @d; } __DATA__ *~ .*cache* .*history* .CFUserTextEncoding .DS_Store .ICEauthority .MacOSX .Trash .Xauthority .cabal .cpan .dbus .dvdcss .easytag .elisp .esd_auth .emacs.d .eshell .firefox .fontconfig* .fonts .gconf* .gimp* .glimpse* .gnome2* .gnucash .gnupg .gstreamer-0.10 .htpasswd .ido.last* .jungledisk* .kde .localized .mozilla .mpd .mplayer .nautilus .navi2ch .nh-todo .pan .projects.ede .qt .recently-used* .rnd .s9x .scribus .skk-* .snes* .ssh .thumbnails .tome .trackballs .uim.d .unison .viminfo .w3m .xchat2* .zcomp* .zfunc