[sf-perl] RE oddity

Rich Morin rdm at cfcl.com
Wed Feb 15 10:56:47 PST 2006

I'm a big fan of extended regular expressions, but I just
wrote one that didn't work as I expected.  This code:

  $line =~ s|[\000-\010                   # nul-bs
              \012-\037                   # nl-us
              \177-\377']                 # del-... and '
            ||gx;                         # Punt weird characters.

produced the nastygram:

  Invalid [] range "l-b" in regex;
  marked by <-- HERE in m/[\000-\010              # nul-b <-- HERE s
                      \012-\037                   # nl-us
                      \177-\377']                 # del-...
                    / at /home/rdm/bin/log_load.pl line 206.

but this code:

  $line =~ s|[\000-\010\012-\037\177-\377']||g;

sails right through.  Is this a bug or a (mis-)feature?


P.S.  "This is perl, v5.8.6 built for x86_64-linux-thread-multi"
Technical editing and writing, programming, and web development:

Contact information: rdm at cfcl.com, +1 650-873-7841

More information about the SanFrancisco-pm mailing list