M
Mark Fenbers
I have an interesting problem...
Perl seems to convert hex numbers which are explicit constants in the code just
fine. For example,
my $val = 0xFF;
is no different from
my $val = 255;
However, if $val is assigned from reading 0xFF from a file or user input, this
natural conversion seems not to occur. $val is treated like a string instead of
a number. I am required to "use strict;" and so I get warnings about this when
I use $val as an argument to a third party (COTS) subroutine that expects a
number instead of a string, e.g., 'Argument "0xFF" isn't numeric in subroutine
entry at (eval 2) line 10.'
I tried something like this:
int($val)
but get a similar error:
'Argument "0xFF" isn't numeric in int at myscript.pl line 98.'
The bottom line is how can I convert a string into an integer or a float??
Mark
Perl seems to convert hex numbers which are explicit constants in the code just
fine. For example,
my $val = 0xFF;
is no different from
my $val = 255;
However, if $val is assigned from reading 0xFF from a file or user input, this
natural conversion seems not to occur. $val is treated like a string instead of
a number. I am required to "use strict;" and so I get warnings about this when
I use $val as an argument to a third party (COTS) subroutine that expects a
number instead of a string, e.g., 'Argument "0xFF" isn't numeric in subroutine
entry at (eval 2) line 10.'
I tried something like this:
int($val)
but get a similar error:
'Argument "0xFF" isn't numeric in int at myscript.pl line 98.'
The bottom line is how can I convert a string into an integer or a float??
Mark