Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
annon { $label => ...} with out assignment is seen as a list?
#!/usr/bin/env perl
use strict;
use warnings;
use Test::Most qw{no_plan};
my $data = [{ label => {key => 'value'}}];
eq_or_diff
[ map{ my $hash = $_;
my $x =
{ map { my $label = $_;
$label => $hash->{$label}
} keys %$hash
}
} @$data
],
[ map{ my $hash = $_;
#my $x =
{ map { my $label = $_;
$label => $hash->{$label}
} keys %$hash
}
} @$data
],
q| annon { $label => ...} with out assignment is seen as a list? |;
__END__
not ok 1 - annon { $label => ...} with out assignment is seen as a list?
# Failed test ' annon { $label => ...} with out assignment is seen as a list? '
# at data_eq.t line 17.
# +----+----------------------+----+--------------------+
# | Elt|Got | Elt|Expected |
# +----+----------------------+----+--------------------+
# | 0|[ | 0|[ |
# | | * 1| 'label', *
# | 1| { | 2| { |
# * 2| label => { * 3| key => 'value' *
# * 3| key => 'value' * | |
# * 4| } * | |
# | 5| } | 4| } |
# | 6|] | 5|] |
# +----+----------------------+----+--------------------+
1..1
# Looks like you failed 1 test of 1.
@schwern

This comment has been minimized.

Show comment Hide comment
@schwern

schwern Sep 29, 2011

I think it's interpreting the braces as a bare block.

schwern commented Sep 29, 2011

I think it's interpreting the braces as a bare block.

@schwern

This comment has been minimized.

Show comment Hide comment
@schwern

schwern Sep 29, 2011

You can stick "scalar" or + in front of the { to force Perl to interpret it as a hash ref.

schwern commented Sep 29, 2011

You can stick "scalar" or + in front of the { to force Perl to interpret it as a hash ref.

@notbenh

This comment has been minimized.

Show comment Hide comment
@notbenh

notbenh Sep 29, 2011

Ahhhh. Bare block that makes sence.

Owner

notbenh commented Sep 29, 2011

Ahhhh. Bare block that makes sence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment