Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Scalar followed by parenthetical...

by LanX (Chancellor)
on May 19, 2013 at 03:34 UTC ( #1034187=note: print w/replies, xml ) Need Help??


in reply to Scalar followed by parenthetical...

ehm ... something completely different!

If you meant to write:

$_->{B} ||= $_->{A} foreach @h;

you should be warned about another bug!

I doubt that you really want $_->{B} to be overwritten if it's 0 or "".

Always use defined-or // to check for undef!

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: Scalar followed by parenthetical...
by Anonymous Monk on May 19, 2013 at 04:36 UTC
    actually I did want $_->{B} to be overwritten... just got bitten in my code where I forgot the "->" for the "A" side, but didn't see a warning. Thanks all!
      Thanks for sharing your error. I learned a lot from the explanations.
      Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1034187]
help
Chatterbox?
[stevieb]: perldigious You should start by writing some unit tests. That'll ensure current functionality doesn't break with changes.
[choroba]: unit tests++
[choroba]: The only problem you can't solve by adding more tests is the problem of having too many tests.
[stevieb]: choroba Been there, done that :) Better too many than not enough though!
[stevieb]: I very often write a base set of unit tests before writing any code. It helps dictate the API, and ensures my earliest of ideas stay on track.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2017-07-21 20:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (335 votes). Check out past polls.