in reply to Get Parent Directory : redefined
in thread Get Parent Directory
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 :).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Get Parent Directory : redefined
by Ananda (Pilgrim) on Oct 23, 2002 at 04:06 UTC |