develooper Front page | perl.perl5.porters | Postings from June 2008

Re: Empty regex

Thread Previous | Thread Next
From:
alfie
Date:
June 18, 2008 21:55
Subject:
Re: Empty regex
Message ID:
54201.59.167.195.42.1213851288.squirrel@www.share-house.com.au
> It's easy to generate a warning for such code, whether it is a good
> idea to do so is a different matter entirely.
>

Why wouldn't it be a good idea? I've just been burned. I'm sure a hell of
a lot of others have too. Seeing as MJD created that RFC in 2000 shows
even he might have been burned.

Can somebody show me when current behavior of /$empty/ would *ever* be a
good idea? I just don't get it. if I do:

  if ( $string =~ /$possible_empty/ ) {
    ...
  }

when $possible_empty *is* empty, I *want* to test as empty, meaning *do
exactly* the same as split //. I don't understand why split() has this
only exception... if it was a good idea at the time for split, why not for
everything!

Sorry for my tone. I'm just a bit depressed that I fell into the booby
trap :)

Alfie

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About