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

[ID 20010719.003] precompiled regular expression having differenttrailing modifiers

Craig Smith - SW design/FW
July 19, 2001 15:26
[ID 20010719.003] precompiled regular expression having differenttrailing modifiers
Message ID:

This is a bug report for perl from,
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";
  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.


[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:
    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
    cc='gcc', optimize='-O', gccversion=
    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/, 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:

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