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

Re^6: Bug in Class::Struct?

by Your Mother (Archbishop)
on Apr 23, 2020 at 21:23 UTC ( [id://11115983]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11115983]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found