Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Binary decoder

by neniro (Priest)
on Feb 11, 2005 at 08:39 UTC ( [id://430017]=CUFP: print w/replies, xml ) Need Help??

Sometime ago, some insane guy posted a lot of binary into a thread on a german news-forum. First I thougt it could be a kind of simple riddle so I tried to convert it to ASCII to see what it is, but it was just binary-polution. That's the conversion script:
#!/usr/bin/perl use strict; use warnings; while(<DATA>) { chomp; my @cur = split(//, $_); my $val = 0; for (0..7) { $val += pop(@cur) * 2**$_; } print $., "\t", $val, "\t", chr($val), "\n"; } __DATA__ 01101010 10010101 01010101 01011011 01001101 01101010 10011011 01010000

Replies are listed 'Best First'.
Re: Binary decoder
by merlyn (Sage) on Feb 11, 2005 at 09:08 UTC
      Hello merlyn,
      I'm not allergic, just ignorant. I'll promise to reread perlpacktut soon.

      thanks in advance,
      neniro

Re: Binary decoder
by Aristotle (Chancellor) on Feb 19, 2005 at 02:14 UTC

    Look ma, no unpack!

    #!/usr/bin/perl use strict; use warnings; while(<DATA>) { our $val = 0; # in-regex code is a closure... () = $_ =~ /1(?{$val+=1<<(pos()-1)})/g; print $., "\t", $val, "\t", chr($val), "\n"; } __DATA__ 01101010 10010101 01010101 01011011 01001101 01101010 10011011 01010000

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://430017]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found