in reply to Re: Re: Idiomatic Perl
in thread Idiomatic Perl

flyingmoose,
This won't work for the reason I described above. If $increment is undefined looks_like_number will still return true.
#!/usr/bin/perl use strict; use warnings; use Scalar::Util 1.10 'looks_like_number'; my $total = 4; my $increment; $total += looks_like_number($increment) ? $increment : 0 __END__ Use of uninitialized value in addition (+) at blah.pl line 9.
Cheers - L~R

Replies are listed 'Best First'.
Re: Re: Re: Re: Idiomatic Perl
by flyingmoose (Priest) on Mar 03, 2004 at 00:11 UTC
    Fair enough. That was typed in the middle of a boring telecom (as are most of my posts), so that explains my inability to read.