The m/\G.../g match can be called several times, and each time it will start at the position where last time it left off.echo "/home/code/work" |\ perl -nle 'chomp; print $p .= $& while m{ \G (?: [^/]* /+ | [^/]+ \z ) + }xg'
However be aware, that this one-liner produces a little different tree than your example, but probably you want to represent the real file system tree and this result is a better representation of it.
In reply to Re: Regular expression parse pathname
by rubasov
in thread Regular expression parse pathname
by unixguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |