Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1015745]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2021-12-02 07:50 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (17 votes). Check out past polls.