Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Different defaults it was, hard coded ran fine, but made the dissection less obfu :-( On my box $| is the problem, $| is 1, which flushes your JAPH too :-) print"\$?:$? \$^F:$^F \$|:$|\n"; $?:0 $^F:2 $|:1 So this runs $_="011291020310415102805081036150812103801030115081"; s/(..)/\\x$1/g;eval"\$_=\"$_\";";print,if($_=join'',map{ chr((vec($_,$?,2*$^F).vec($_,$|,4))+96)}split//)=~s;~; ;g; Disection follows (of the hard code) now that the use of: $?:0 $^F:2 $|:1 has been let out of the bag tachyon # this is what vec is # # another running dissection by tachyon # # code string $_="011291020310415102805081036150812103801030115081"; # this line grabs pairs from $_ and add hex escapes s/(..)/\\x$1/g; # this gives: # $_='\x01\x12\x91\x02\x03\x10\x41\x51\x02\x80\x50\x81\x03\x61\x50\x81 +\x21\x03\x80\x10\x30\x11\x50\x81'; # the function of this line is to convert the hex # escapes to their ascii representation due to the # interpolation that occurs to $_ eval"\$_=\"$_\";"; # the code below summarises these two steps # but it is now more obvious what is going on # uncomment it and this still runs so it must be right! # $_="011291020310415102805081036150812103801030115081"; # $_ =~ s/(..)/chr hex $1/eg; # I will rearrange this to make it easier to understand print, if($_=join'',map{chr((vec($_,0,4).vec($_,1,4))+96)}split//)=~s; +~; ;g; # first lets reset $_ using my shortened code $_="011291020310415102805081036150812103801030115081"; $_ =~ s/(..)/chr hex $1/eg; # split up our chars @ascii = split//,$_; #now we replace the map with this boring loop for (@ascii) { push @decode, chr((vec($_,0,4).vec($_,1,4))+96); } # join the decoded chars $_ = join'', @decode; # sub out the ~ chars s/~/ /g tr/~/ / s;~; ;g; #print it print "\n$_"; # so now all we need to understand is what vec does: # # vec EXPR, OFFSET, BITS # # The vec function provides a compact storage of lists of # unsigned integers. These integers are packed as tightly as # possible within an ordinary perl string. EXPR is treated as a # bit string. OFFSET specifies the index of the particular # element. BITS specifies how wide each element is in bits. # # So what happens is that for each eight bits we grab two # nybbles (4 bits) giving us 0-15 decimal after 'vec'ing. # we concat these together, run that through chr and # bob's your uncle

In reply to Re: What's vec? by tachyon
in thread What's vec? by iamcal

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others cooling their heels in the Monastery: (5)
    As of 2024-07-25 10:47 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found

      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.