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 :).


Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Replies are listed 'Best First'.
Re: Re: Get Parent Directory : redefined
by Ananda (Pilgrim) on Oct 23, 2002 at 04:06 UTC
    Hello BrowserUK, Thanks for the clarificationa and the code . It's perfectly what i wanted. Greetings!!!! Anandatirtha