Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: YAML::XS perl/regexp (?u:(?u:

by tinita (Parson)
on Dec 08, 2017 at 16:54 UTC ( #1205184=note: print w/replies, xml ) Need Help??


in reply to Re: YAML::XS perl/regexp (?u:(?u:
in thread YAML::XS perl/regexp (?u:(?u:

It would be possible to store a regex as a sequence and use the same tag for it:
--- re1: !!perl/regexp (?^usi:pattern) re2: !!perl/regexp [ pattern, isu ]
For perl 5.8 the old behaviour could be used. This could be done for YAML and YAML::XS. Possibly also for YAML::Syck, which has the same problem, but I would have to ask Todd, the maintainer.

Replies are listed 'Best First'.
Re^3: YAML::XS perl/regexp (?u:(?u:
by ikegami (Pope) on Dec 19, 2017 at 19:29 UTC

    You can add understanding of !!perl/regexp [ pattern, isu ] at any time, but backwards compatibility requires making the generation of that an option. Eventually, once support has been established, it could default to the new method.

      Another possibility would be to continue just using a string. Check with regexp_pattern(), if there are any flags (ignoring u), just store the stringified regex, otherwise store the pattern itself. This would still lead to unnecessary (?:...) but it wouldn't grow in roundtrips.
      Have been looking into universal.c how regexp_pattern() is implemented. At the moment it's too much magic for me to understand.

        I don't know what you mean by "check with regexp_pattern(), if there are any flags (ignoring u)". Do you mean "check if the results of ( regexp_pattern(qr/$pat/) )[1] contains anything but u"? It never will (unless you use use re "/...", which would be bad here).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1205184]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2019-10-17 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?