arithmetic on alphanumeric in PERL
Hi,
Is it possible to do arithmetic on alphanumeric data? Eg: say i get the input as 01F01,01F02 etc. If i have to generate the numbers till "n", what should my datatype read to perform the operation. And also let me know how to do it. Thanks, ~ gaynut |
interpretted in what radix, hexidecimal? Yes, just prefix with "0x" when interpreting, and use printf to format as hex:
Code:
printf "%x\n", (0x2 * 0xf); |
Usually, what I prefer to do is to set up a regular-expression, which extracts the "useful" parts of the information while also being sure that the input actually does conform to the expected syntax.
Perl provides a full complement of "printf/scanf"-type formatting routines, and it's also pretty darned smart when it's "type-casting" information to-and-from a string. This is to be expected, since Perl is really a power-tool for manipulating strings. As you explore your project, look first at CPAN. Open your mind to any possibility that you can find. No matter what you are setting out to do, CPAN has probably already done it. You will either find complete applications or modules that will give you a huge head-start... |
All times are GMT -5. The time now is 10:13 AM. |