my $path = "/home/temp/login"; use File::Spec; my @paths = File::Spec->splitdir($path); print "\"$_\"\n" for @paths; __END__ "" "home" "temp" "login"