#!/usr/bin/perl use warnings; # no warnings 'recursion'; use strict; my $filename = $ARGV[0] // "core"; my $dir = '/' // '.'; chdir $dir; go ($dir); sub go{ my ($dir) = shift; # print "DIR: $dir\n"; my @l = glob (".* *"); for my $i (@l){ next if ($i =~ /^\.\.$/ || $i =~ /^\.$/); if ($i =~ /$filename/){ # if (-f $filename){ # unless (-l $filename || -p $filename || -s $filename){ # double check print "SUCCESS: $dir$filename\n"; # or whatever # } # } } my $newdir = $dir.$i."/"; next unless -d $newdir; next if ($newdir =~ /\/proc\// || $newdir =~ /\/sys\//); if ( (chdir $newdir) ) { go ($newdir); } } }