Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -w use strict; die if !(@ARGV); my @codes = qw(61 31 21 1 44 16 21 11 7 9 37 39 33 3 2 1 0 32 51 41 10 +); open TARGET,"$ARGV[0]"; open NEW,">$ARGV[0]\.c"; print NEW "#include <EXTERN.h>\n#include <perl.h>\n\n"; print NEW "extern void xs_init();\n"; print NEW "static PerlInterpreter *perl;\n\nvoid main() {\n"; print NEW " int execute[] = {"; my $total = 0; my $counter = 0; my $beginning = 1; while(<TARGET>) { my @tmp = split //,$_; $total += $#tmp; for(my $i=0;$i<=$#tmp;$i++) { my $check = $tmp[$i]; if($beginning) { $beginning = 0; $tmp[$i] = ord($tmp[$i])+$codes[$counter]; print NEW $tmp[$i]; } else { $tmp[$i] = ord($tmp[$i])+$codes[$counter]; print NEW ",".$tmp[$i]; } $counter++; $counter = 0 if $counter>$#codes; } $total++; } print NEW ",0};\n int i = 0;\n int codes[] = {61,31,21,1,44,16,2 +1,11,7,9,37,39,33,3,2,1,0,32,51,41,10};\n char *embedding[] = +{ \"\",\"-e\",\"0\" };\n"; print NEW " char str[".$total."];\n"; print NEW " int count = 0;\n"; print NEW " while(execute[i]!=0) {\n str[i] = (char) +(execute[i] - codes[count]);\n"; print NEW " i++;\n count++;\n + if(count>40) count=0;\n }\n str[i]='\0';\n"; print NEW " perl = perl_alloc();\n perl_construct(perl);\n + perl_parse(perl,xs_init,3,embedding,NULL);\n perl_run(pe +rl);\n eval_pv(str,TRUE);\n perl_destruct(perl);\n per +l_free(perl);\n}"; close TARGET; close NEW; open MAKE,">make"; my $name = $ARGV[0]; print MAKE "perl -MExtUtils::Embed -e xsinit -- -o perlxsi.c "; while(shift @ARGV) { if($ARGV[0]) { print MAKE $ARGV[0]," "; } } print MAKE "\n"; print MAKE "cc -c perlxsi.c `perl -MExtUtils::Embed -e ccopts`\n"; print MAKE "cc -c $name\.c `perl -MExtUtils::Embed -e ccopts`\n"; print MAKE "cc -o exe perlxsi.o $name\.o `perl -MExtUtils::Embed -e ld +opts -- -std DynaLoader `\n"; `chmod 700 ./make`; close MAKE;

In reply to Transformation by Alex the Serb

Title:
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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (7)
    As of 2020-10-27 13:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My favourite web site is:












      Results (256 votes). Check out past polls.

      Notices?