Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a binary file which contains a bunch of various strings. Is there such a way to convert those into numbers?

Replies are listed 'Best First'.
Re: Convert strings into numbers
by moritz (Cardinal) on Jul 13, 2009 at 17:21 UTC
Re: Convert strings into numbers
by roboticus (Chancellor) on Jul 13, 2009 at 23:27 UTC

    You certainly don't give us much to go on. There are many ways to convert strings to numbers. One or two of them might even be useful to you.

    Perl knows how to convert some strings to numbers. Here's an example:

    my $string = "123"; my $number = $string+0;

    Perhaps the number you want is the length of the string? This would do it:

    my $stringlen = length($string);

    Perhaps you wanted a different conversion? If so, you might tell us what sort of conversion you're interested in...

    </snarky_mode>

    ...roboticus