in reply to eval not working the way I expected?

You can use $SIG{__WARN__} to detect warnings (see %SIG) or the warnings pragma to make them FATAL so eval/$@ catch them (see perllexwarn).
  • Comment on Re: eval not working the way I expected?

Replies are listed 'Best First'.
Re^2: eval not working the way I expected?
by convenientstore (Pilgrim) on Jan 09, 2008 at 20:14 UTC
    try few of that and get back to you guys
    thanks as always
      should below syntax work?
      I tried it and I thought no matter what , worse thing it would do is assign 0 value to $report{$_}, but I still see error messages
      $report{$_} = sprintf("%.2f", eval {( ( $stop{$_} / 60000 ) / $stop_2 +{$_})} || 0 );
        I got rid of eval as replace it w/ below and seem to work well
        Problem now is that I cannot access the hash outside of block.. why?? meaning when I do a dump on hash,(which had element in it ; by printing inside of loop) , nothing comes up.
        my (%report_ccr,%report_asr); my (%report_ccr_o,%report_asr_o); my (%report_stop, %report_o_stop); for (sort keys %totalcalls_o) { my $start_o_f = ($start_o{$_}) ? $start_o{$_} : 0; #for stop record outbound side; if (exists $stop_outbound{$_}) { #print "\$stop_o{$_} is $stop_o{$_}\n"; #print "\$stop_outbound{$_} is $stop_outbound{$_}\n"; $report_o_stop{$_} = sprintf("%.2f", ( ( $stop_outbound{$_} + / 60000 ) / $stop_o{$_})) ; #resultsin min mark #print "\$report_o_stop{$_} is $report_o_stop{$_}\n"; } elsif (defined $crank_o{$_}) { $report_ccr_o{$_} = sprintf("%.2f" , ( ( $start_o_f / ($tota +lcalls_o{$_} - $crank_o{$_}) ) * 100 )); $report_asr_o{$_} = sprintf("%.2f" , ( ( $start_o_f / $total +calls_o{$_}) * 100 )); #print "\$report_ccr_o{$_} is $report_ccr_o{$_}\n"; #print "\$report_asr_o{$_} is $report_asr_o{$_}\n"; } else { $report_asr_o{$_} = sprintf("%.2f" , ( ( $start_o_f / $total +calls_o{$_}) * 100 )); # print "from last \$report_asr_o{$_} is $report_asr_o{$_}\n +"; } } print "going dumper\n"; print Dumper(%report_ccr_o);