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

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

William Lanahan
April 5, 2003 17:14
[perl #21843] fail on substituting values into s/// construct
Message ID:
# New Ticket Created by  William Lanahan 
# Please include the string:  [perl #21843]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
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]
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:
    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
    cc='cc', ccflags ='-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    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:

Environment for perl v5.6.1:
    LANG (unset)
    LANGUAGE (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/ksh Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About