in reply to Re: Re: Re: Re: Re: split/map weirdness: empty strings vs undef
in thread split/map weirdness: empty strings vs undef

Yes. That's exactly my point. My examples showed that /|/ and '|' were the same. For completeness:

$string = "2|3||"; print "Backwhacked bar in pattern: "; print "($_)" for split /\|/, $string; print "\n"; print "Backwhacked bar in quotes: "; print "($_)" for split '\|', $string; print "\n"; print "Just a bar in pattern: "; print "($_)" for split /|/, $string; print "\n"; print "Just a bar in quotes: "; print "($_)" for split '|', $string; print "\n"; __END__ Backwhacked bar in pattern: (2)(3) Backwhacked bar in quotes: (2)(3) Just a bar in pattern: (2)(|)(3)(|)(|) Just a bar in quotes: (2)(|)(3)(|)(|)

The presence of bars in the output of both splitting on '|' and on /|/ is because those are both really splitting on the null pattern. The quoted bar is not preserving fields.

-sauoq
"My two cents aren't worth a dime.";
  • Comment on Re: Re: Re: Re: Re: Re: split/map weirdness: empty strings vs undef
  • Download Code