I just ran across something puzzling.  Why are these two statements not 
equivalent when it comes to warnings?
        
if ($item->{'optionprice'}) {
        $item->{'unitprice'} += $item->{'optionprice'};
}

and

$item->{'unitprice'} += $item->{'optionprice'} if ($item->{'optionprice'});

        Given the following values:
        
$item->{'unitprice'}   = '12.16';
$item->{'optionprice'} = '';

the 2nd statement returns an "Argument '' isn't numeric in addition (+)" 
warning, while the 1st one doesn't.  I thought I read where Peal reads a 
statement like the 2nd one from right to left.  It looks like it doesn't, since 
$item->{'optionprice'} is evaluated in spite of the 'if'.  Am I mistaken?

Perl 5.10.1

Thanks,
Frank

SurfShop shopping cart is now open source...

http://www.surfshopcart.com/
Setting up shop has never been easier!

Follow us on GitHub!
https://github.com/surfshopcart/surfshop


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to