in reply to Re^4: Summing the odd/even digits of a larger number (for upc check digits)...a better way?
in thread Summing the odd/even digits of a larger number (for upc check digits)...a better way?

I'm convinced. I just tried out your example, and added a case because I wasn't certain that evaluating a conditional would yield the same as a conditional return. Then, as I've never used Data::Dump::Streamer I also added a case with an explicit undef, just to be certain...

$condRes = condReturn (0); print 'condReturn (0) '; Dump ($condRes); $condRes = condReturn (1); print 'condReturn (1) '; Dump ($condRes); sub condReturn { return "Foobar" if shift == 1; } $condRes = mebbeUndef (0); print 'mebbeUndef (0) '; Dump ($condRes); $condRes = mebbeUndef (1); print 'mebbeUndef (1) '; Dump ($condRes); sub mebbeUndef { return undef if shift == 0; }
...and got the expected:

condReturn (0) $VAR1 = ''; condReturn (1) $VAR1 = 'Foobar'; mebbeUndef (0) $VAR1 = undef; mebbeUndef (1) $VAR1 = '';
--roboticus
  • Comment on Re^5: Summing the odd/even digits of a larger number (for upc check digits)...a better way?
  • Select or Download Code