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

[perl #21565] backslash bug: '\\' interpreted as '\'

Thread Next
Per Olav Kroka
March 13, 2003 07:18
[perl #21565] backslash bug: '\\' interpreted as '\'
Message ID:
# New Ticket Created by  "Per Olav Kroka (ETO)" 
# Please include the string:  [perl #21565]
# in the subject line of all future correspondence about this issue. 
# <URL: >

The intention of my script was to find all C-style compiler directives.

Bug description:
I had to enter a quadruple backslash (\\\\) to make it interpret this as a single one in the search statement. In my opinion it should only have been a double backslash (\\) and I tried using that, but then it was interpreted as an escape character and it resulted in too few closing parantheses. 


My script:
#!/usr/bin/perl.exe -w
use warnings;
use strict;

undef $/; #enable whole file mode

        my $hash     = '^[\t ]*\#(?>.+)(?:(?<=\\\\)\n.*)*\n{1}';   # #  compiler directives
        #                                       ^-- The bug:
        # I had to enter a quadruple backslash to make it interpret this as a single one in 
        # the search statement below.
        print "Hash test: ";
        while( /($hash)/gm )
                print "\"";
                print $1;
                print "\"";
                print "\n";
        print "\n";
#script ends here

Version: (perl -V output)
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
    osname=cygwin, osvers=1.3.2(0.3932), archname=cygwin-multi
    uname='cygwin_nt-4.0 loreley 1.3.2(0.3932) 2001-05-20 23:28 i686 unknown '
    config_args='-de -Dusemultiplicity'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=define
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -I/usr/local/include',
    cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='2.95.3-5 (cygwin special)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld2', ldflags =' -s -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib
    libs=-lgdbm -lcrypt
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl5_6_1.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
    cccdlflags=' ', lddlflags=' -s -L/usr/local/lib'

Characteristics of this binary (from libperl):
  Built under cygwin
  Compiled at Aug 22 2001 01:05:05

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About