in reply to How to cut the directory path?

You can use File::Spec directly if you want

use strict; use warnings; use File::Spec; my(undef,$dir,$file)=File::Spec->splitpath( 'c:\Perl\bin\perl.exe' ); my @dirs = File::Spec->splitdir($dir); # splitdir returns some '' empty dirs # docs tell: # Unlike just splitting the directories on the separator, empty direct +ory names ('' ) can be returned, # because these are significant on some OSes. # # infact adding # use Data::Dump; dd @dirs; # returns # ("", "Perl", "bin", "") # because of this i use the last one among those who contain something # or (grep {/./} @dirs)[-1] print File::Spec->catfile('',(grep {/./} @dirs)[-1],$file); # the first empty '' passed to catfile is needed if you want the leadi +ng separator

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.