develooper Front page | perl.perl5.porters | Postings from September 2000

Re: [ID 20000901.008] Scoping (?) oddities with pos()

Thread Previous
From:
Ronald J Kimball
Date:
September 1, 2000 06:24
Subject:
Re: [ID 20000901.008] Scoping (?) oddities with pos()
Message ID:
20000901092349.A441512@linguist.dartmouth.edu
On Fri, Sep 01, 2000 at 11:05:42AM +0100, Mike Guy wrote:
> There seem to be funny scoping effects with pos():
> 
> #perl -wl
> $x = 'a' x 200 . 'b';
> { $x =~ /b/g; };
> print pos $x;
> { $x =~ /b/g; $y = pos $x };
> print "$y ", pos $x;
> print do { $x =~ /b/g; pos $x };
> __END__
> 201
> Use of uninitialized value in concatenation (.) or string at - line 5.
> Use of uninitialized value in print at - line 5.
>  
> 201
> 
> Test is with bleedperl, but the same behaviour goes back to at least
> 5.004_04.

I think that pos() has the same scope as the string, not the match, and so
the above behavior is correct.

Ronald

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About