2002/07/14/path/content #### use strict; use File::Find; use File::Spec; my $search = File::Spec->canonpath("/".shift()); 1 while $search =~ s!/[^/]+/\.\./?!/!; $search =~ s!^/!!; find({ wanted => \&wanted, preprocess => \&preprocess, # this should do it follow => 1, }, "."); sub wanted { return unless -d; print "testing $File::Find::name\n"; # see these fine if (glob("$_/${search}.*")) { print "$File::Find::name/$search\n"; exit; } } sub preprocess { print "pre-processing @_\n"; # never see this return sort { $b <=> $a } grep { /^\d+$/ } @_; } #### [fastolfe@home test]$ ./resolve-name /path/content testing . testing ./2001 testing ./2001/05 testing ./2001/05/30 ./2001/05/30/path/content