in reply to Exploiting Perls idea of what is a number

$temp1=eval { 0+$value1 }; $temp1=$value1 if $@; Perl says it is not a number
Ummm ... under what circumstances can that first line of code possibly set $@ ?

Update: moritz has provided a very plausible answer to that question.

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: Exploiting Perls idea of what is a number
by moritz (Cardinal) on Jul 08, 2008 at 13:46 UTC
    Under the influence of use warnings FATAL => qw(numeric);
      Under the influence of use warnings FATAL => qw(numeric);

      Actually, just writing use warnings; is sufficient. Example:

      use strict; use warnings; my $value="abc"; my $t=eval { 0+$value }; print "$@\n";
      prints Argument "abc" isn't numeric in addition (+) at U:\develsv\ARTS\playground\eval_test1.pl line 4.

      -- 
      Ronald Fischer <ynnor@mm.st>

        It does print that, but not because $@ is set. Here's a slight modification:

        use strict; use warnings; my $value="abc"; my $t=eval { 0+$value }; print "OMG: $@\n"; __END__ Argument "abc" isn't numeric in addition (+) ... OMG: