From: "Sayed, Irfan (Irfan)" <[EMAIL PROTECTED]>
> Can somebody please help me on following doubt.....
Question. You may doubt our ability to help you with your questions,
but still what you have is a question, not a doubt. Please
distinguish the two.
> But still my doubt exist. How Perl knows that it has to stop at the @
> character
>
> As per your suggestion , I have written like this.
>
> my $project="aic_8.0wewew@/vobs/pvob_aic";
> print "$project\n";
> my ($pvob) = ($project =~ m{(.+@)});
> print "$pvob\n";
>
> and now it is taking @ in output so now how Perl knows that it has to
> stop at @ character.
>
> As per my understanding, (.+) this means any character with any no. of
> times then why it is not taking all the character.
>
> why the output is not coming as "aic_8.0wewew@/vobs/pvob_aic" and why it
> is coming as aic_8.0wewew@
Because the whole regexp has to match, not just the (.+). So what the
regexp engine does with that regexp is that it first matches the .+
to the whole string, finds out there is nothing left so the @ cannot
match, it backs one character so the .+ now matches only
"aic_8.0wewew@/vobs/pvob_ai" and tries whether @ matches "c", finds
out that it doesn't, backtracks some more until .+ matches only
"aic_8.0wewew" at what point the @ can match and as it's the last
thing in the regexp we are done.
You might try to install "The Regex Coach" http://weitz.de/regex-
coach/
and play with a bit it to get a better graps of regexps.
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/