William schreef:
> Hello, if I use the sprintf function it would give me a number
> STRING, but not number, so I have to trick the string to become
> number by adding and subtracting the number with 1. Is there a better
> way than this ? I want it to be a number data type and not string.
>
> e.g
>
> my $strNumber = sprintf("%04d", 123);
> my $number = $strNumber + 1 - 1; # to trick Perl to convert to number
> datatype instead of string.
my $number = 0+ $strNumber;
or "in place":
$strNumber += 0;
But there really is no need! The first time you use the variable as a
number, it will become a number (or rather a numeric reality will be
added to it), which is used in further numeric contexts.
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/