#!/usr/bin/perl -wT use strict; use File::Spec; use Data::Dumper qw(Dumper); use constant PATH => '/One/Two/Three'; #split up the path into directory segments my @dirs = File::Spec->splitdir(PATH); my @paths; while(my $path = File::Spec->catfile(@dirs)) { push @paths, $path; pop @dirs; } print Dumper(\@paths); #### $VAR1 = [ '/One/Two/Three', '/One/Two', '/One' ];