Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.94k stars 554 forks source link

$^N is ((only) secretly) readonly #12031

Closed p5pRT closed 12 years ago

p5pRT commented 12 years ago

Migrated from rt.perl.org#112184 (status was 'resolved')

Searchable as RT112184$

p5pRT commented 12 years ago

From tchrist@perl.com

The $^N variable is not assignable\, but attempting to do so raises no exception​:

  % perl -wle '"foo" =~ /(\w)/; print $^N'   f   % perl -wle '"foo" =~ /(\w)/; print $^N = 1'   f   % perl -wle '"foo" =~ /(\w)(?{ $^N = 2})/; print $^N = 1'   f

Contrast with $1​:

  % perl -wle '"foo" =~ /(\w)/; print $1'   f   % perl -wle '"foo" =~ /(\w)/; print $1 = 1'   Modification of a read-only value attempted at -e line 1.   Exit 255

--tom

Summary of my perl5 (revision 5 version 14 subversion 0) configuration​:  
  Platform​:   osname=openbsd\, osvers=4.4\, archname=OpenBSD.i386-openbsd   uname='openbsd chthon 4.4 generic#0 i386 '   config_args='-des'   hint=recommended\, useposix=true\, d_sigaction=define   useithreads=undef\, usemultiplicity=undef   useperlio=define\, d_sfio=undef\, uselargefiles=define\, usesocks=undef   use64bitint=undef\, use64bitall=undef\, uselongdouble=undef   usemymalloc=y\, bincompat5005=undef   Compiler​:   cc='cc'\, ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'\,   optimize='-O2'\,   cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'   ccversion=''\, gccversion='3.3.5 (propolice)'\, gccosandvers='openbsd4.4'   intsize=4\, longsize=4\, ptrsize=4\, doublesize=8\, byteorder=1234   d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12   ivtype='long'\, ivsize=4\, nvtype='double'\, nvsize=8\, Off_t='off_t'\, lseeksize=8   alignbytes=4\, prototype=define   Linker and Libraries​:   ld='cc'\, ldflags ='-Wl\,-E -fstack-protector -L/usr/local/lib'   libpth=/usr/local/lib /usr/lib   libs=-lgdbm -lm -lutil -lc   perllibs=-lm -lutil -lc   libc=/usr/lib/libc.so.48.0\, so=so\, useshrplib=false\, libperl=libperl.a   gnulibc_version=''   Dynamic Linking​:   dlsrc=dl_dlopen.xs\, dlext=so\, d_dlsymun=undef\, ccdlflags=' '   cccdlflags='-DPIC -fPIC '\, lddlflags='-shared -fPIC -L/usr/local/lib -fstack-protector'

Characteristics of this binary (from libperl)​:   Compile-time options​: MYMALLOC PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP   PERL_PRESERVE_IVUV USE_LARGE_FILES USE_PERLIO   USE_PERL_ATOF   Built under openbsd   Compiled at Jun 11 2011 11​:48​:28   %ENV​:   PERL_UNICODE="SA"   @​INC​:   /usr/local/lib/perl5/site_perl/5.14.0/OpenBSD.i386-openbsd   /usr/local/lib/perl5/site_perl/5.14.0   /usr/local/lib/perl5/5.14.0/OpenBSD.i386-openbsd   /usr/local/lib/perl5/5.14.0   /usr/local/lib/perl5/site_perl/5.12.3   /usr/local/lib/perl5/site_perl/5.11.3   /usr/local/lib/perl5/site_perl/5.10.1   /usr/local/lib/perl5/site_perl/5.10.0   /usr/local/lib/perl5/site_perl/5.8.7   /usr/local/lib/perl5/site_perl/5.8.0   /usr/local/lib/perl5/site_perl/5.6.0   /usr/local/lib/perl5/site_perl/5.005   /usr/local/lib/perl5/site_perl   .

p5pRT commented 12 years ago

From @cpansprout

On Sun Apr 01 08​:20​:52 2012\, tom christiansen wrote​:

The $^N variable is not assignable\, but attempting to do so raises no exception​:

% perl \-wle '"foo" =~ /\(\\w\)/; print $^N'
f
% perl \-wle '"foo" =~ /\(\\w\)/; print $^N = 1'
f
% perl \-wle '"foo" =~ /\(\\w\)\(?\{ $^N = 2\}\)/; print $^N = 1'
f

Contrast with $1​:

% perl \-wle '"foo" =~ /\(\\w\)/; print $1'
f
% perl \-wle '"foo" =~ /\(\\w\)/; print $1 = 1'
Modification of a read\-only value attempted at \-e line 1\.
Exit 255

There is a fix waiting on the sprout/misc-post-5.16 branch.

--

Father Chrysostomos

p5pRT commented 12 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 12 years ago

From @cpansprout

Fixed by d9bad346a1.

p5pRT commented 12 years ago

@cpansprout - Status changed from 'open' to 'resolved'