in reply to Recursively walk up a directory tree

No need for recursion, a loop is just fine:
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use Path::Tiny; my $path = 'Path::Tiny'->cwd; $path = path("$path/..")->realpath until -e "$path/.marker" || '/' eq $path; say -e "$path/.marker" ? 'F' : 'Not f', 'ound';

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Recursively walk up a directory tree
by 1nickt (Canon) on Feb 11, 2018 at 01:51 UTC

    Thanks choroba, I knew there must be a way with until! Maybe even more elegant as:

    my $path = Path::Tiny->cwd; $path = $path->parent until -f "$path/.marker" or $path->is_rootdi +r;


    The way forward always starts with a minimal test.
Re^2: Recursively walk up a directory tree
by Your Mother (Archbishop) on Feb 11, 2018 at 00:05 UTC

    Isn't relying on cwd less robust than using __FILE__? I guess I'm having trouble coming up with what might chdir/cd on/under the script, so maybe not.