[Dancer-users] befuddling Dancer error

Puneet Kishor punk.kish at gmail.com
Sun Mar 18 15:56:55 CET 2012


great explanation. Makes perfect sense now. Many thanks.

On Mar 18, 2012, at 9:52 AM, Daniel Perrett <dperrett at cambridge.org> wrote:

> This is what looks like is happening:
> 
> $h is the empty string. $nodata_valu is a very big number.
> 
> ($h == $nodata_valu) generates a warning because $h is not a number, it is the empty string. It also is false, so the 'else' is executed.
> 
> The sprintf statement coerces $h to a number then converts that number to a string with 2 decimal places.
> 
> The value of the sprintf is assigned to $h.
> 
> The debug line then prints the two scalars.
> 
> Daniel
> 
> -----dancer-users-bounces at perldancer.org wrote: -----
> To: dancer-users <dancer-users at perldancer.org>
> From: "Mr. Puneet Kishor" 
> Sent by: dancer-users-bounces at perldancer.org
> Date: 03/18/2012 02:54AM
> Subject: [Dancer-users] befuddling Dancer error
> 
> I have the following code
> 
>     if (defined $h) {
>         $h = ($h == $nodata_valu) ? $nodata_desc : sprintf("%.2f", $h);
>         debug "h: $h, nodata: $nodata_valu";
>     }
> 
> which results in the following log entry
> 
>     [63130] debug @0.154003> [hit #4]h: 0.00, nodata: -3.40282346638529e+38
> 
> Yet,I get the following Dancer error
> 
>     Warning caught during route execution: Argument "" isn't numeric in numeric eq (==) at  
>         if (defined $h) {
>             $h = ($h == $nodata_valu) ? $nodata_desc : sprintf("%.2f", $h); 
>             debug "h: $h, nodata: $nodata_valu";
>         }
> 
> 
> what gives?
> 
> 
> 
> --
> Puneet Kishor
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20120318/b5a4c700/attachment.htm>


More information about the Dancer-users mailing list