#!/usr/bin/perl -w use strict; use File::Basename; my $fullpath = '\\Server\dir\user'; my $popped; my @fileparts; while($fullpath ne "" && ($popped = basename($fullpath)) ) { push @fileparts, $popped; $fullpath = dirname($fullpath); } for(@fileparts) {print "$_\n"}