Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Strange YAML behavior with lists of qr regexp values

by Anonymous Monk
on Jan 28, 2013 at 18:33 UTC ( #1015745=note: print w/ replies, xml ) Need Help??


in reply to Strange YAML behavior with lists of qr regexp values

It doesn't seem to have anything to do with the adding of new patters.

Instead, YAML::Syck's LoadFile() function seems to always add a level of brackets around all regexes it reads from a YAML file, even if they already have outer brackets.

Example:

test-re.pl:

#!/usr/bin/perl use strict; use warnings; use YAML::Syck qw(LoadFile); use Data::Dumper; my $yaml = LoadFile( 'test-re.yaml' ); print Dumper($yaml->{patterns}), "\n";

test-re.yaml:

--- patterns: - !!perl/regexp (?^i:^foo.*bar.*baz) - !!perl/regexp ^quux$

Output:

$VAR1 = [ qr/(?^:(?^i:^foo.*bar.*baz))/, qr/(?^:^quux$)/ ];

Output when changing use YAML::Syck to use YAML:

$VAR1 = [ qr/(?^ui:^foo.*bar.*baz)/, qr/(?^u:^quux$)/ ];

So yeah, seems to be a YAML::Syck particularity. Whether it is a bug is a matter of opinion I guess, since the regexes do behave the same so nothing should break.


Comment on Re: Strange YAML behavior with lists of qr regexp values
Select or Download Code
Re^2: Strange YAML behavior with lists of qr regexp values
by naChoZ (Curate) on Jan 30, 2013 at 15:06 UTC

    I notice that YAML::XS is similarly affected. Storing regular expressions themselves obviously must not be on too many radars. ;)

    --
    Andy

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2014-07-31 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls