Skip to content

weird behaviour, newline in $path #24

@davewood

Description

@davewood

depending on the input of a "value eq ..." query I get a string or a HASH ref.

code

#!/usr/bin/env perl
use 5.018;
use warnings;

use Data::DPath::Path;

sub _match {
    my ($path, $input) = @_;
    my $dpath  = Data::DPath::Path->new( path => $path );
    my @result = $dpath->match($input);

    use Data::Dumper;
    say "###\n$path";
    say Dumper(\@result);
}

my $input = { 'details' => 'foo bar baz' };

my $path1 = <<"HERE";
/details[ value eq 'foo bar baz' ]
HERE

my $path2 = <<"HERE";
/details[ value eq 'foo bar
baz' ]
HERE

_match($path1, $input);
_match($path2, $input);

output

###
/details[ value eq 'foo bar baz' ]

$VAR1 = [
          'foo bar baz'
        ];

###
/details[ value eq 'foo bar
baz' ]

$VAR1 = [
          {
            'details' => 'foo bar baz'
          }
        ];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions