If I understand you, this may be what you are wanting.
#! perl use warnings; # Always use this, it will help you enormously. use strict; # And this also. use diagnostics; # This gives some very useful hints when you are +developing. #I assume that this will come from somewhere else. my $path = "\\default\\main\\Anand\\toipcs\\Tutorials\\internet"; # And that you know this or know how to find it out (hint: use Cwd; is + one way). my $CurDir = 'Anand'; # And that what you want its find the parts before and after the curre +nt directory in the path my ($Pdir, $Sdir) = $path =~ m!(.+)Anand\\toipcs(.+)!; print "Pdir = '$Pdir' and Sdir = '$Sdir'\n";
When the above program is run, it produces the following output.
c:\test>207011 Pdir = '\default\main\' and Sdir = '\Tutorials\internet' c:\test>
I hope this helps, if not or if I can clarify anything for you, ask away :).
In reply to Re: Get Parent Directory : redefined
by BrowserUk
in thread Get Parent Directory
by Ananda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |