in reply to Re: Basic transformations
in thread Basic transformations

The trick is that perl will evaluate a literal number as hex if you prefix it with '0x', you then need to use eval to force perl to re-evalute it as a number instead of a string.
Any reason not use the build in hex function, and instead use an eval, which, if the data comes from an untrusted source, has potential to have some "unwanted"side effects?

Replies are listed 'Best First'.
Re^3: Basic transformations
by chrestomanci (Priest) on Nov 30, 2010 at 12:36 UTC

    Only that I did not think to use hex. It would probably be a better approach than eval.

    I don't think the OP had reason to distrust the input data, but if he did then it would be wise to sanitise with a regular expression like:my($clean) = ($raw =~ m/(\d+)/); regardless of how it is processed further.

      So, his example data isn't going to pass the sanitizing?