Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Bits & pieces

by jdalbec (Deacon)
on Jul 16, 2005 at 03:18 UTC ( [id://475403]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $_ = [
        [
    ...
        ]
    ];
    (%_) = %{ ${ ${ $_; }[0]; }[1]; };
    
  2. or download this
    undef $_;
    %_ = (
    ...
                65 => '011100001001010100000001'
    #                  012345678901234567890123
    );
    
  3. or download this
    $s = eval {
        do {
    ...
    
          }
    };
    
  4. or download this
    $o = pack( 'b*', $_{9} );
    foreach $_ ( 0 .. unpack( '%b*', $o ) - 2 ) {
    # 16 bit checksum = 25, - 2 = 23
    
  5. or download this
        $c = $_ - ( ( $_ - $_ % 4 ) / 4 + ( $_ % 4 ? 1 : 0 ) );
    # print $c;
    ...
    #    1010  0010  0000  1111  0001  0100  0000  0100  1000  1000  0101 
    + 0100
    # J  u  r  t        n  o  u  h  e  r     P  d  r  l  a  h  a  b  j  e 
    + r
    #       *        *        *                 *        *        *  *
    
  6. or download this
        $i += $i % 2 ? -1 : 1 # $i ^= 1
          if ( $_ + 1 ) % 12 and not(( $_ + 1 ) % 3)
    ...
    # print $i % 16;
    # 10 5 3 4 0 1 14 15 4 8 5 2 0 0 5 2 12 0 8 1 3 11 5 2
    # J  u s t   a n  o  t h e r   P e r l    h a c k  e r
    
  7. or download this
        $T =
          vec( pack( 'C', $i ), 0, 4 ) + vec( pack( 'b*', $_{65} ), $_, 1 
    +) * 16 +
    ...
    # 0  1  1  1  0  0  0  0  1  0  0  1  0  1  0  1  0  0  0  0  0  0  0 
    + 1
    # J  u  s  t     a  n  o  t  h  e  r     P  e  r  l     h  a  c  k  e 
    + r
    # *  1  2  3  4  5  6  7  8  9  10 11 12 *  1  2  3  4  5  6  7  8  9 
    + 10
    
  8. or download this
        print pack( 'c', ( $T += $T == 32 ? 0 : 64 ) -= $_ % 13 == 0 ? 32 
    +: 0 );
    
  9. or download this
    #    &$s; # independent of rest of loop, unrolled
    }
    ...
    # 00   14294967295  2105  38   44294967263  573   68   74294967263  87
    +7
    # 94   104294967291 1153  120  134294967295 14116 1520 164294967263 17
    +112
    # 1813 194294967282 20125 2116 224294967295 23116
    
  10. or download this
    print pack( 'c', &$s(1) ^ unpack( 'c', pack( 'b*', $_{72} ) ) );
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found