in reply to Re^5: Bug in Class::Struct?
in thread Bug in Class::Struct?

That’s very interesting…

perl -MYAML -E '$vol = "asdf"; $x = { moo => scalar($vol =~ m/^HOLDING +/) }; say $x->{moo} == 0' 1

But also, to me at least, very surprising and I wouldn’t want to see it in code.

Replies are listed 'Best First'.
Re^7: Bug in Class::Struct? (updated)
by haukex (Archbishop) on Apr 23, 2020 at 21:30 UTC

    I guess it depends: mapping it to a different value, as in bool ? 1 : 0, will definitely make it more clear (and also force scalar context). But using scalar is better than not using it at all, since if you've got a hash { moo => $vol =~ m/^HOLDING/, foo => 'bar' } that's asking for trouble (and in some cases, security holes, like with CGI.pm's param).

    Update: Corrected the example hash