LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl>>working with strings (https://www.linuxquestions.org/questions/programming-9/perl-working-with-strings-8749/)

format_c 11-15-2001 08:27 AM

Perl>>working with strings
 
Hi I have a little problem.
Is there a command that can transform a string into Numbers (binary code)?

Like

$string="Test"
$stringnew=unknowncommand ($string)
print $stringnew

Result: 11100011110010001111000110101100101
or 124564534785536

Is there any command which can do this???

How is that syntax???

Please help.


:newbie:

http://www.toxicarea.de/creed/images/banner_gr.jpg CREED for EVER

malakai6276 11-15-2001 01:35 PM

Well, you could always write your own method to accomplish this [duh...]. Otherwise... if i remember correctly, i think the "Wolf book" has some information about string manipulations using bit operations via perl code. I think the title is "mastering algorithms with perl", a great book btw. Go to borders or barnes&nobles or some other book store with an extensive CS section, they should have it ...

mikeb 11-15-2001 04:21 PM

numbers to binary
 
try
printf "%b", 12;
for binary of 12 = 1100
and
printf "%vb", 12;
for binary of 1 and 2 = 110001.110010
or
printf "%vb", "test";
for binary of t.e.s.t = 1110100.1100101.1110011.1110100
:jawa:


All times are GMT -5. The time now is 01:47 AM.