in reply to Restarting File::Find
#!/usr/bin/perl -- use strict; use warnings; use Path::Tiny qw/ path /; print existingParent( 'C:/WINDOWS/roshambonotexist/bl/ah/di/blah' ),"\ +n"; print existingParent( 'Q:/a/b/c/d/e/f/g/h/i/j/k/l' ),"\n"; sub existingParent { my $dir = path( shift )->absolute; while( not $dir->exists ){ $dir = $dir->parent; last if $dir->is_rootdir; } return $dir if $dir->exists; return ""; } __END__ $ perl path-tiny-parent.pl C:/WINDOWS [download]
www.com | www.net | www.org
No recent polls found