develooper Front page | perl.perl5.porters | Postings from July 2001

[ID 20010719.003] precompiled regular expression having differenttrailing modifiers

From:
Craig Smith - SW design/FW
Date:
July 19, 2001 15:26
Subject:
[ID 20010719.003] precompiled regular expression having differenttrailing modifiers
Message ID:
200107192210.SAA25492@xena.vgi.com

This is a bug report for perl from craig_smith01@yahoo.com,
generated with the help of perlbug 1.19 running under perl 5.00403.


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


Perhaps it is fixed under later versions of perl, but I do not have an 
installation to check.

Create a precompiled regular expression with out
trailing modifier.  Then when the precompiled regular expression is used add 
a trailing modifier to ignore case. The perl interpreter will ignore the
trailing modifier 'i' since it was not part of the original precompiled
regexp.  I believe that the precompiled regex should take precedence, however
a warning message should be generated if the compiled regex's modifiers differ
from the usage modifiers.  


Here is a sample program:

$string = "the FBI is watching you";
$regex = qr{fbi};

if ( $string =~ /$regex/i )
{
  print "match found\n";
}
else
{
  print "no match\n";
}

the warning message could be:

"modifier of precompiled regex does not match modifier at point of use - at
 line 4"


The desire of the precompiled regex is different from the usage and the 
programmer should be warned of this.

Obviously this is only important if $regex contains a precompiled regex and
not a regex in a string. 

This brings up the cunumdrum--what if no modifier is specified at point of
usage? Does this mean you want to use the precompiled regex modifiers?
No modifiers present could be ambiguous--either you don't care what modifiers
the precompiled regex brings, or you want to remove them.

Here is a weird idea: should a new modifier be introduced that specifies that 
the modifiers from the precompiled regex should be used (sounds like 
inheritance) forcing the programmer to specify priority?

This, I believe, could all be avoided if a different syntax for precompiled
regular expressions was used. It seems that the regex operator is overloaded
a bit too much.

Craig









[Please do not change anything below this line]
-----------------------------------------------------------------

---
Site configuration information for perl 5.00403:

Configured by root at Thu Sep 11 13:14:51 EDT 1997.

Summary of my perl5 (5.0 patchlevel 4 subversion 3) configuration:
  Platform:
    osname=solaris, osvers=2.5.1, archname=sun4-solaris
    uname='sunos xena 5.5.1 generic sun4m sparc sunw,sparcstation-20 '
    hint=previous, useposix=true, d_sigaction=define
    bincompat3=n useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.7.2.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, randbits=15
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-fPIC'
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'


---
@INC for perl 5.00403:
	/ah/csmith/lib/perl
	/ah/csmith/lib/perl5
	/usr/local/lib/perl5.004_03/sun4-solaris/5.00403
	/usr/local/lib/perl5.004_03
	/usr/local/lib/perl5.004_03/site_perl/sun4-solaris
	/usr/local/lib/perl5.004_03/site_perl
	.

---
Environment for perl 5.00403:
    HOME=/ah/csmith
    LANG (unset)
    LC_COLLATE=en_US.ISO8859-1
    LC_CTYPE=en_US.ISO8859-1
    LC_MESSAGES=C
    LC_MONETARY=en_US.ISO8859-1
    LC_NUMERIC=en_US.ISO8859-1
    LC_TIME=en_US.ISO8859-1
    LD_LIBRARY_PATH=../OBJsolaris:../OBJsolaris:/ibs/installed/lib:/ibs/sybase/lib:/usr/local/lib:/usr/local/lib:/usr/lib:/usr/ucblib
    LOGDIR (unset)
    PATH=.:/ah/csmith/bin:/ah/csmith/bin/sun4:/local/bin:/usr/local/bin:/usr/local/gnu/bin:/usr/local/etc:/local/X11R5/bin:/usr/local/X11R5/bin:/usr/bin/X11:/local/openwin/bin:/usr/openwin/bin:/usr/ccs/bin:/usr/bin:/bin:/usr/ucb:/usr/etc:/etc:/usr/sbin:/ibs/installed/bin:/ibs/os_support/bin:/ibs/sybase/bin:/sqa/bin:/usr/local/AcroRead/bin:/ah/csmith/bin/solaris:/ah/csmith/bin/perl
    PERL5LIB=/ah/csmith/lib/perl:/ah/csmith/lib/perl5
    PERL_BADLANG (unset)
    SHELL=/bin/csh




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