develooper Front page | perl.perl5.porters | Postings from November 2012

[perl #115834] Successfull match $_[0] =~ /foo(.+)/ overrides $_[0] if function called as foo($1)

Thread Previous | Thread Next
From:
sp @ smartspb . net
Date:
November 20, 2012 13:31
Subject:
[perl #115834] Successfull match $_[0] =~ /foo(.+)/ overrides $_[0] if function called as foo($1)
Message ID:
rt-3.6.HEAD-17500-1353345435-1984.115834-75-0@perl.org
# New Ticket Created by  sp@smartspb.net 
# Please include the string:  [perl #115834]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=115834 >


This is a bug report for perl from sp@smartspb.net,
generated with the help of perlbug 1.39 running under perl 5.16.1.


-----------------------------------------------------------------
Successfull match $_[0] =~ /foo(.+)/ inside subroutine
overrides $_[0] if subroutine called as foo($1).

###### script ###### sp@uskr:~/3 (1570) cat u.pl
use strict; use warnings; use feature qw(:all);

sub foo {
    say '  before =~ $_[0] is ', "'$_[0]'";
    $_[0] =~ /foo(.+)/;
    say '  after  =~ $_[0] is ', "'$_[0]'", ' and $1 is ', "'$1'";
}

# ok

say 'call foo("foo123");';
foo('foo123');

# at least strange

say 'call foo($1);';
'barfoo123' =~ /(foo.+)/ && foo($1);

###### output ###### sp@uskr:~/3 (1571) perl u.pl

call foo("foo123");
  before =~ $_[0] is 'foo123'
  after  =~ $_[0] is 'foo123' and $1 is '123'
call foo($1);
  before =~ $_[0] is 'foo123'
  after  =~ $_[0] is '123' and $1 is '123'

sp@uskr:~/3 (1572)

###### summary ######

I'm not sure is that bug or feature.
I could not find something describing such things in docs.


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.16.1:

Configured by sp at Thu Oct 11 12:45:42 MSK 2012.

Summary of my perl5 (revision 5 version 16 subversion 1) configuration:
   
  Platform:
    osname=freebsd, osvers=9.0-release, archname=amd64-freebsd
    uname='freebsd uskr 9.0-release freebsd 9.0-release #0: tue jan 3 07:46:30 utc 2012 root@farrell.cse.buffalo.edu:usrobjusrsrcsysgeneric amd64 '
    config_args='-de -Dprefix=/site/perl5/perls/perl-5.16.1 -Aeval:scriptdir=/site/perl5/perls/perl-5.16.1/bin'
    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=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-O',
    cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 20070831 patched [FreeBSD]', 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='cc', ldflags ='-Wl,-E  -fstack-protector -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil -lc
    perllibs=-lm -lcrypt -lutil -lc
    libc=, 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  -L/usr/local/lib -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.16.1:
    /site/perl5/perls/perl-5.16.1/lib/site_perl/5.16.1/amd64-freebsd
    /site/perl5/perls/perl-5.16.1/lib/site_perl/5.16.1
    /site/perl5/perls/perl-5.16.1/lib/5.16.1/amd64-freebsd
    /site/perl5/perls/perl-5.16.1/lib/5.16.1
    .

---
Environment for perl 5.16.1:
    HOME=/home/sp
    LANG=ru_RU.UTF-8
    LANGUAGE (unset)
    LC_ALL=ru_RU.UTF-8
    LC_COLLATE=ru_RU.UTF-8
    LC_CTYPE=ru_RU.UTF-8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/site/perl5/bin:/site/perl5/perls/perl-5.16.1/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
    PERLBREW_BASHRC_VERSION=0.52
    PERLBREW_HOME=/home/sp/.perlbrew
    PERLBREW_MANPATH=/site/perl5/perls/perl-5.16.1/man
    PERLBREW_PATH=/site/perl5/bin:/site/perl5/perls/perl-5.16.1/bin
    PERLBREW_PERL=perl-5.16.1
    PERLBREW_ROOT=/site/perl5
    PERLBREW_VERSION=0.52
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash


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