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

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

Thread Previous | Thread Next
From:
sthoenna
Date:
September 1, 2000 13:35
Subject:
Re: [ID 20000901.008] Scoping (?) oddities with pos()
Message ID:
WRBs5gzkgiRR092yn@efn.org
In article <E13Unhe-0000uo-00@draco.cus.cam.ac.uk>,
Mike Guy <mjtg@cam.ac.uk> 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

Nothing to do with scoping.  The second match fails (only one b in $x).

[D:\home\sthoenna]perl -wl
$x = ('a'x200).'b';
$x =~ /b/g; print pos $x;
$x =~ /b/g; print pos $x;
$x =~ /b/g; print pos $x;
__END__
201
Use of uninitialized value in print at - line 3.

201

Thread Previous | Thread Next


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