Re: Extrating String using Split



"Ashwin" <Ashwin@DoNot@Email.com> wrote:
> Hi All
> I have following code,
>
> my $Loc="C:\\Temp\\testing_disp\\Internal";
> my
> @alldir=("C:\\Temp\\testing_disp\\Internal\\A","C:\\Temp\\testing_disp\\
> Internal\\B","C:\\Temp\\testing_disp\\Internal\\C");
>
> where A,B,C are deeper directory tree what I need, is to split so that
> I get directory tree A,
>
> The problem if I use below code it complains
> my @finaldir=map((split(/$Loc/))[1],@alldir);
> Unrecognized escape \T passed through before HERE mark in regex m/C:\T
> << HERE emp\testing_disp\Internal/
>
> even
> @finaldir=map(/$Loc(.*)/,@alldir);
> fails with the same error
> even if I remove reference to "c:" I still cannot split


Read about \Q in perldoc perlretut.

>
> Question is how to extract rest of tree;

something like: /\Q$Loc\E(.*)/

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.