On 17 February 2013 02:56, Tom Christiansen <tchrist@perl.com> wrote: > I've seen people try to do this: > > my $delim = $if_something ? " " : qr/\s+/; > @fields = split $delim, $string; > > And they are *very* surprised that it doesn't work the same as > > @fields = split $if_something ? " " : /\s+/, $string; > > That is really hard to explain, you know? Not easy to justify either. > > Either it should clearly state that this space trick is a magic literal > literal and that cannot be in variable, or else it should be fixed so > anything that shows up as a U+0020 counts as that. Well it looks like this isnt going to be easy at all. And frankly I don't understand why some of the changes were done. It looks like FC in an attempt to fix a "bug" (of dubious provenance) ended up making this kind of thing a lot harder, and in fact you could argue that the change that FC made in 5255171e6cd0accee6f76ea2980e32b3b5b8e171 completely makes this impossible. I personally think that commit was a mistake, and that #94490 should have been marked as "not a bug". I regret I didnt spot it at the time. Had 5255171e6 not been committed fixing this would have been possible. /grrrrr Yves git log -SSKIPWHITE commit cccd1425414e6518c1fc8b7bcaccfb119320c513 Author: Father Chrysostomos <sprout@cpan.org> Date: Thu Oct 11 09:27:18 2012 -0700 Define RXf_SPLIT and RXf_SKIPWHITE as 0 They are on longer used in core, and we need room for more flags. The only CPAN modules that use them check whether RXf_SPLIT is set (which no longer happens) before setting RXf_SKIPWHITE (which is ignored). commit 5255171e6cd0accee6f76ea2980e32b3b5b8e171 Author: Father Chrysostomos <sprout@cpan.org> Date: Sat Sep 22 17:54:12 2012 -0700 [perl #94490] const fold should not trigger special split " " The easiest way to fix this was to move the special handling out of the regexp engine. Now a flag is set on the split op itself for this case. A real regexp is still created, as that is the most convenient way to propagate locale settings, and it prevents the need to rework pp_split to handle a null regexp. This also means that custom regexp plugins no longer need to handle split specially (which they all do currently). commit 7bd1e61447493a93405e0d15fe2f8a0b6bf71de1 Author: Yves Orton <demerphq@gmail.com> Date: Thu Jun 28 22:14:14 2007 +0000 Replace pattern parsing logic with optree "parsing" logic. p4raw-id: //depot/perl@31496 commit 0ac6acaed7c2092a5668c6b70ddeaf3003e989d8 Author: Ævar Arnfjörð Bjarmason <avar@cpan.org> Date: Thu Jun 28 20:06:50 2007 +0000 Move the RXf_WHITE logic for split " " into the regex engine From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com> Message-ID: <51dd1af80706281306i4dbba39em3eeb8da1d67ea27c@mail.gmail.com> (with tweaks) p4raw-id: //depot/perl@31495 -- perl -Mre=debug -e "/just|another|perl|hacker/"Thread Previous | Thread Next