in reply to Regular expression parse pathname
use 5.010; my $_ = "/home/code/work"; my @paths; again: unshift @paths, $_; s!/[^/]*$!! and length $_ and goto again; say "@paths"; __END__ /home /home/code /home/code/work [download]