On Fri, 7 Jun 2002, Luke Palmer wrote:
> > Dave Storrs wrote:
> > Can we please have a 'reverse x' modifier that means "treat whitespace as
> > literals"? Yes, we are living in a Unicode world now and your data could
> >
> > /FATAL ERROR\: Process (\d+) received signal\: (\d+)/
>
> I don't see how this example is nearly as flexible as this:
>
> m:w/FATAL ERROR\: Process (\d+) recieved signal\: (\d+)/
>
> Yours will only match 4 spaces after FATAL ERROR:, whereas mine will match
> any number. [...]
> I see the :w modifier as a good flexibility enforcement. It will
> keep people away from matching things that very literally.
Respectfully, Luke, I think you and I are discussing separate
issues. You are talking about the best way to match multiple
whitespace--and I agree with what you're saying, one should never assume
that it will always be 4 spaces instead of 5. Were I writing that code in
a real project, instead of as a demo for the list, I would use \s+ (in P5,
anyway...in P6, whether I would use \s+ or \h+ would depend on
circumstances).
However, the point I was making was that, if I feel confident in
only handling a limited subset of the possibilities because I know what
I'm going to be getting (because, e.g., I wrote it out myself), then I
would like a way to do away with the visual clutter involved in
backwhacking or entity-izing every bit of whitespace. Perl has never been
a nanny-language...one of its greatest strengths has always been that it
trusts me to make my own decisions and, if I want to shoot myself in the
foot, I can. :>
The suggestions that other people have been making about defining
subrules and then building them up in order to make the entire match are
good, and in general that's a very powerful technique. However, the lines
devoted to those subrules still count as visual clutter, and I'd still
like a way to do away with them.
Dave