The array contents are ... #### my @a = qw/C:\abc\dfg\axy C:\abc\dfg\#@$#@$@\hwllo/; for ( @a ) { my @p = split /\\/; print "last-component= ", $p[-1], " and next-to-last= ", $p[-2], "\n"; }