develooper Front page | perl.perl5.porters | Postings from April 2003

[perl #21843] fail on substituting values into s/// construct

From:
William Lanahan
Date:
April 5, 2003 17:14
Subject:
[perl #21843] fail on substituting values into s/// construct
Message ID:
rt-21843-54573.6.09276607147834@bugs6.perl.org
# New Ticket Created by  William Lanahan 
# Please include the string:  [perl #21843]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21843 >


This is a bug report for perl from wlanahan@smithers.lz.att.com,
generated with the help of perlbug 1.33 running under perl v5.6.1.


#!/usr/bin/perl -w

#This is perl, v5.6.1 built for sun4-solaris

#Copyright 1987-2001, Larry Wall

# if I try to fill in s/$from/$to/$modifier, I get error below
# yet hard coding a modifier like 'g' works fine, as does s/$from/$to/

#Scalar found where operator expected at ./bug line 20, near "s/$from/$to/$modifier"
#syntax error at ./bug line 20, near "s/$from/$to/$modifier"
#Unterminated <> operator at ./bug line 20.




	my ($from, $to, $modifier);

$respBuf = "hello world";

$line = "l|L|g";  # this won't work
#$line = "l|L|";  # <=== ok

		chomp( $line );
		($from, $to, $modifier) = split('\|', $line);
	
		eval { "" =~ /$from/ } if $from;
		eval { "" =~ /$to/ } if $to;

print "DEBUG ORIGINAL respBuf=<$respBuf>\n";
print "DEBUG from=<$from>\n";
print "DEBUG to=<$to>\n";
print "DEBUG modifier=<$modifier>\n";

		if ( "${modifier}" ) {
			$respBuf =~ s/$from/$to/$modifier;  <== causes ERROR
			#$respBuf =~ s/$from/$to/g; <== OK
		} else {
			$respBuf =~ s/$from/$to/;
		}

print "DEBUG FINAL respBuf=<$respBuf>\n";


-----------------------------------------------------------------
[Please enter your report here]



[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.6.1:

Configured by chesla at Thu Mar 14 09:56:02 EST 2002.

Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris
    uname='sunos sassy 5.8 generic_108528-13 sun4u sparc sunw,ultra-60 '
    config_args='-Dinstallprefix=/sas_base/perl/buildperl/instperl -Dprefix=/usr/local -der'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='cc', ccflags ='-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-I/usr/local/include'
    ccversion='Sun WorkShop 6 2000/04/07 C 5.1', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib -L/opt/SUNWspro/WS6/lib '
    libpth=/usr/local/lib /opt/SUNWspro/WS6/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldb -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib -L/opt/SUNWspro/WS6/lib'

Locally applied patches:
    

---
@INC for perl v5.6.1:
    /usr/local/lib/perl5/5.6.1/sun4-solaris
    /usr/local/lib/perl5/5.6.1
    /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.6.1
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    /usr/local/lib/perl5/site_perl
    .

---
Environment for perl v5.6.1:
    HOME=/home/wlanahan
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH=:/usr/lib/hpnp/lib:/usr/openwin/lib
    LOGDIR (unset)
    PATH=/sablime/bin/SBCS/bin:/sablime/bin:/sablime/sbin:/usr/sbin:/usr/bin:/home/wlanahan/bin:/usr/local/bin:.:/usr/bin:/usr/ccs/bin:/usr/ucb:/usr/local/bin:/usr/openwin/bin:/opt/exptools/bin
    PERL_BADLANG (unset)
    SHELL=/bin/ksh




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