On 2011-11-29 14:49, Chris Stinemetz wrote:

  How can I check that the value assigned to $cell and $sector is numeric
before I try to call the sprintf function?

I am just trying to clear this warning.

Argument "" isn't numeric in sprintf at ./rt_evdo_pcmd.pl line 139,<$FIN>
line 119503.

line 139 is from my program is below:

my $c_s = sprintf("%d_%d",$cell,$sector);


To check if a variable is numeric, see Igor's suggestion to apply looks_like_number.


About sprintf:

I almost always use %s, and only use the %d and %i ones for special formatting, like %04d.

So either go with John's suggestion, or make it

  my $c_s = sprintf q{%s_%s}, $cell, $sector;

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to