Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: indirection

by diotalevi (Canon)
on Mar 25, 2003 at 16:24 UTC ( [id://245713]=note: print w/replies, xml ) Need Help??


in reply to indirection

Each pair in @japh (I reformatted $q into @japh for convenience) encodes two or three pieces of information. Each number is split as a nibble and a byte. If the nibble in the first number is non-zero then the byte from the second number is an offset into $data to find a two byte hex encoded character. If the nibble was zero then each byte specifies an index into $data to retrieve the two nibbles of the two byte hex encoded character. The first number's byte is the most significant nibble in that value.

The de-obfuscated source

#!/usr/bin/perl -w use strict; my $c = sub {substr shift(), 0, 2 }; my $d = sub {substr shift(), 0, 1 }; my $f = sub { $_[1] ->( $_[0] ) }; my $data = join '', map sprintf( '%02x', $_ & 1 ? $_ : 255 - $_ ), 0 .. 255; my @japh = ( [qw[082 15E]], [qw[258 0B1]], [qw[258 071]], [qw[258 091]], [qw[042 002]], [qw[258 0C2]], [qw[124 028]], [qw[258 0DE]], [qw[258 16F]], [qw[0C2 0F0]], [qw[258 0CA]], [qw[258 051]], [qw[1A0 00A]], [qw[258 015]], [qw[258 134]], [qw[258 1AF]], [qw[0C2 064]], [qw[1A4 1F4]], [qw[0D6 116]], [qw[258 13C]], [qw[258 0C6]], [qw[258 0D6]], [qw[0C2 1EB]], [qw[1F1 1A0]], [qw[258 042]], [qw[1F4 0A0]]); while (my $chr = shift @japh) { my ($l, $r) = map hex(), @$chr; print chr hex ($l >= 501 ? substr($data, $r, 2) : substr($data, $l, 1) . substr($data, $r, 1) ); }

Replies are listed 'Best First'.
Re: Re: indirection
by iamcal (Friar) on Mar 31, 2003 at 11:12 UTC
    Beautifully done :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-07-19 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.