in reply to How to split "/"

Yet another way to do it with the core module File::Spec:

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

The initial empty string at $paths[0] is due to the initial slash in the path (root directory).