#!/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
In reply to Re: Restarting File::Find
by beech
in thread Restarting File::Find
by Preceptor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |