Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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.


#!/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";


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


$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.

Replies are listed 'Best First'.
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. ;)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015745]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2018-02-25 16:37 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (314 votes). Check out past polls.