[sf-perl] RE oddity

David Alban extasia at extasia.org
Wed Feb 15 13:10:13 PST 2006


The following works:

 $line =~ s|  # foo
            [\000-\010
             \012-\037
             \177-\377']  # bar
           # bat
           ||gx;                         # Punt weird characters.

I think perl is considering your comments part of the character class
in your original example, even though you've used /x.

On 2/15/06, Rich Morin <rdm at cfcl.com> wrote:
> 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.

--
Live in a world of your own, but always welcome visitors.


More information about the SanFrancisco-pm mailing list