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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

This is my answer to Ovid's Perl is C: my entry to the 4th Obfuscated Perl Contest.

#include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <fcntl.h> #define open(a,b) open(b,a) #define $ARGV argv #define $i i #define x : /* aren't four #define way too much? unshift @ARGV, $_ = $ARGV[0]; "*/ main(int argc, char *argv[]) { // "; { int m=1, i[14]; char * pp; int p=-1; int q, F=3; char * qq = "Hello\, world!\n"; i[12]=537463307; i[13]=3085; //,; $_ = "" if(length!=2); if(m+-p?(argc>1&&!strcmp(argv[1],"-p"))?p+i? 1 : 1 x 0 x 0) { printf(qq/*\bThe Perl Journal\n/#*/ ); exit(0); } qq="=;#"; argv[0][0]='\0'; memset(i,0,48); $i[10]=($i[11]=(q/*\b/&&scalar@ARGV))-1;#*/=0) + argc)-1; do{ if($i[11]<2) { $i[10]=1; q/*/&&*F=*STDIN;#*/=F=0; } else { open(O_RDONLY, $ARGV[$i[11]-$i[10]]);//; *F=*O_RDONLY; } while(read(F, $i, 1)>0) { ++$i[4]^(q=/*.=,$_=$i);#*/0); pp=i; $i[3]+=m=( *pp^0x0A)?/*\n=;#*/0:1; for(qq=&i[12];*qq;*pp^*qq++|| +(q=1)); if(m=/*[ \n\f\r\xB]=#*/q ) { if($i[1]){$i[$i[1]]++; $i[1]=0; }} else { $i[1]=2;} } if($i[1]){$i[$i[1]]++;}; printf("%7d %7d %7d %s\n",$i[3],$i[2],$i[4],$ARGV[$i[11]-$i[10]]); close(F); if($i[11]>2){for($i[1]=2;$i[$i[1]+4]+=$i[$i[1]];$i[1]++){$i[$i[1]] +=0;};$i[1]=0;} } while(--$i[10]); if($i[11]>2) { printf("%7d %7d %7d total\n",$i[7],$i[6],$i[8]); } }

You can name is wc.c and compile it as a C program and a Perl program. The name says it all.

Be careful: one line contains an embedded tabulation.


In reply to C is Perl by BooK

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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 cooling their heels in the Monastery: (10)
    As of 2014-07-25 07:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (169 votes), past polls