Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Opposite of strtol?

by ysth (Canon)
on Jun 21, 2009 at 19:15 UTC ( #773409=note: print w/replies, xml ) Need Help??

in reply to Re: Opposite of strtol?
in thread Opposite of strtol?

A Perl scalar will pretend to be a number or a string as the circumstances require, so you do not need a "string to/from number" function.
You do if you want a non-base-2/8/10/16 string representation.
Actually, <c>POSIX::strtol<c> does not "parse a string representation of a number in any base into a number" but does a "String to (long) integer translation", which is quite different, but in Perl --IMO-- seldom useful.
In principle, yes, but if you know it will work with the range of numbers you have, strtol is possibly fine.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://773409]
[Dumu]: ambrus: it's about testing a file for being multiple possible file formats
[ambrus]: In particular, you might want to detect the encoding of a HTML file from between utf-16 versus ascii-based and encoding given in a META tag.
[ambrus]: Dumu: it should probably be safe to change the encoding if you rewind first with seek $file, 0, 0 first
[Dumu]: ambrus: good guess. I'm trying to contribute to a CPAN module, and the existing tests assume they're looking at text files
[Dumu]: ambrus: thank you. I was seeking afterwards. I'll seek first.
[jedikaiti]: Hello, Dumu!
[Dumu]: hello again jedikaiti! thanks everyone today for being in the monastery!

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2017-11-20 17:59 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (291 votes). Check out past polls.