in reply to Re^2: Recursively walk up a directory tree
in thread Recursively walk up a directory tree

The looping is done by the regex engine, trying to find the longest match, and if it fails, the next longest, etc.

Try adding a print statement inside the code block and you can see each directory before the test for .marker.

Like so:

cwd =~ m#^(.*)(?:/|$)(??{print "testing $1\n"; ! -f "$1/.marker"})# or + die " .marker not found";