Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[perl #70501] "given" doesn't reset pos($_)

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


perlbug-followup at perl

Nov 14, 2009, 12:32 AM

Post #1 of 3 (146 views)
Permalink
[perl #70501] "given" doesn't reset pos($_)

# New Ticket Created by Anno Siegel
# Please include the string: [perl #70501]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=70501 >


This is a bug report for perl from anno5 [at] mac,
generated with the help of perlbug 1.39 running under perl 5.11.1.


-----------------------------------------------------------------
[Please describe your issue here]

I think the topicalizer "given" doesn't reset pos($_) when it should:

for ( 1 .. 3 ) {
my $in = 'abcdefg';
given ( $in ) {
say pos // '-undef-';
pos = 3;
}
}

This prints "-undef-" for the first time through the loop, but "3" for subsequent rounds, showing that pos($_) survives "given". Replacing "given" with "for" changes the behavior.

Regards, Anno

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
This perlbug was built using Perl 5.10.1 - Mon Nov 9 23:54:32 CET 2009
It is being executed now by Perl 5.11.1 - Tue Nov 10 20:30:02 CET 2009.

Site configuration information for perl 5.11.1:

Configured by anno at Tue Nov 10 20:30:02 CET 2009.

Summary of my perl5 (revision 5 version 11 subversion 1 patch v5.11.1-161-gfa58a56) configuration:
Snapshot of: fa58a56f3cdf71021d7d7a49e98845f57652a3fe
Platform:
osname=darwin, osvers=10.0.0, archname=darwin-2level
uname='darwin radom.local 10.0.0 darwin kernel version 10.0.0: fri jul 31 22:47:34 pdt 2009; root:xnu-1456.1.25~1release_i386 i386 '
config_args='-des -Dusemymalloc -Dusedevel -DDEBUGGING -Accflags=-DPERL_DEBUGGING_MSTATS -Dprefix=/usr/local/ports/bleadperl/install -Uversiononly'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=y, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -DPERL_DEBUGGING_MSTATS -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
optimize='-O3 -g',
cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp -DPERL_DEBUGGING_MSTATS -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
ccversion='', gccversion='4.2.1 (Apple Inc. build 5646)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/opt/local/lib'
libpth=/usr/local/lib /opt/local/lib /usr/lib
libs=-ldbm -ldl -lm -lutil -lc
perllibs=-ldl -lm -lutil -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector'

Locally applied patches:


---
@INC for perl 5.11.1:
/Users/anno/lib/perl5
/usr/local/ports/bleadperl/install/lib/site_perl/5.11.1/darwin-2level
/usr/local/ports/bleadperl/install/lib/site_perl/5.11.1
/usr/local/ports/bleadperl/install/lib/5.11.1/darwin-2level
/usr/local/ports/bleadperl/install/lib/5.11.1
.

---
Environment for perl 5.11.1:
DYLD_LIBRARY_PATH (unset)
HOME=/Users/anno
LANG (unset)
LANGUAGE (unset)
LC_CTYPE=de_DE.UTF-8
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/Users/anno/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/local/bin:/opt/local/sbin:/usr/local/pgsql/bin
PERL5LIB=/Users/anno/lib/perl5
PERL_BADLANG (unset)
PERL_UNICODE=SAL
SHELL=/bin/bash


rgs at consttype

Nov 15, 2009, 3:14 AM

Post #2 of 3 (128 views)
Permalink
Re: [perl #70501] "given" doesn't reset pos($_) [In reply to]

2009/11/14 Anno Siegel <perlbug-followup [at] perl>:
> I think the topicalizer "given" doesn't reset pos($_) when it should:
>
>    for ( 1 .. 3 ) {
>        my $in = 'abcdefg';
>        given ( $in ) {
>            say pos // '-undef-';
>            pos = 3;
>        }
>    }
>
> This prints "-undef-" for the first time through the loop, but "3" for
> subsequent rounds, showing that pos($_) survives "given".  Replacing
> "given" with "for" changes the behavior.

I think that a more general form of this was already reported --
given() doesn't remove magic when aliasing to $_.


anno5 at mac

Nov 15, 2009, 9:05 AM

Post #3 of 3 (119 views)
Permalink
Re: [perl #70501] "given" doesn't reset pos($_) [In reply to]

On 15.11.2009, at 12:14, Rafael Garcia-Suarez wrote:

> 2009/11/14 Anno Siegel <perlbug-followup [at] perl>:
>> I think the topicalizer "given" doesn't reset pos($_) when it should:

[demo code]

> I think that a more general form of this was already reported --
> given() doesn't remove magic when aliasing to $_.

Aha! Sorry for not noticing.

Anno

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.