# Set the path variable. $path = "\\default\\main\\Anand\\toipcs\\Tutorials\\internet"; # Make a copy of it $curPath = $path; # Extract (what I assume to be) your user/home directory ("Anand"). # However this line won't work because the substitution operator is missing the 's' $curPath =~ !\default\main\(.*)\Tutorials\internet!$1!; # ^ There should be an 's' here # Make a copy of the extracted directory name ("Anand") and print it out $parentdir = $curPath; print "parent Directory : $curPath\n"; # This line doesn't doesn't make any sense at all??. # It's obviously trying to extract 2 different parts of the path froom something # But # a) The is no variable to operate on! It would need to look something like: # ($Pdir, $Sdir) = $path =~ m!(.*)\\(.*)!; !!!NOTE the doubled backslash (\\)! # b) Quite what the intent of the '$1,$2' at the end was meant to do. ($Pdir,$Sdir) =~ m!(.*)\(.*)$!$1,$2; # Nothing will be printed as the line above did nothing! print "parent branch : $Pdir \t sub branch $Sdir";