> From: Greg London <[EMAIL PROTECTED]>

Greg, did this ever get answered? I'm trying to catch up on my email and didn't 
see a response to this followup. My guess would be because the first instance is 
only matching once, so your getting the pos of the first (and only current) 
match. Since you used the c modifier you should be able to use that regex again 
with the /G (?) anchor in the pattern to have it start at the last match.

The second case the regexp is called in list context, so makes all the possible 
matches. There is no pos afterwards because the last case didn't match - the /g 
was done.

At least that's my guess. However, that might not be the end of this. Look into 
the @- and @+ arrays, which I think (no docs handy) will do what your looking 
for. HTH!

> here's the actual cut and paste code:
> 
> #!/usr/local/bin/perl -w
> use strict;
> 
> 
> my $hstr1 = "fee fie foe foo";
> my $href1 = { string => $hstr1 };
> $href1->{string} =~ m/e/mcg;
> print "position is ".pos($href1->{string})."\n";
> 
> my $hstr2 = "fee fie foe foo";
> my $href2 = { string => $hstr2 };
> my @matches = $href2->{string} =~ m/e/mcg;
> print "position is ".pos($href2->{string})."\n";
> 
> 
> and heres the cut and paste output:
> 
> position is 2
> Use of uninitialized value in concatenation (.) at .//junk.pl line 13.
> position is 
> 
> 
> when I grab the match results by saying:
> 
>       my @matches = ...regexp...
> 
> it seems like it messes up the pos value.
> 
> huh?
> 
> Greg

--------------------------
Sean Quinlan
mailto:[EMAIL PROTECTED]
http://bmerc-www.bu.edu/

"You can discover more about a person in an hour of play than in a year of
conversation" - Plato


Reply via email to