To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 2029
2028  |  2030
Subject: 
Re: Is it perl or C? (was: Re: Programming Brain Teaser)
Newsgroups: 
lugnet.off-topic.geek
Date: 
Wed, 13 Sep 2000 16:20:45 GMT
Reply-To: 
tobias.moller@telia.comSPAMCAKE
Viewed: 
210 times
  
When looking at this, I can't believe I actually wanted to learn how to
program ^-^

I thought it was much more simple, like AppleScript or the POV-ray scene
description language.

--Tobias

David Eaton wrote:
<SNIP>
#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]); }
}

Enjoy!
DaveE•



Message has 1 Reply:
  Re: Is it perl or C? (was: Re: Programming Brain Teaser)
 
(...) Well, this is an example of horrific code, because it was purposely written so that it would parse, compile, and run in two different languages ... actual C code or Perl code is usually much nicer to look at and understand. BUT, let it be said (...) (24 years ago, 13-Sep-00, to lugnet.off-topic.geek)

Message is in Reply To:
  Is it perl or C? (was: Re: Programming Brain Teaser)
 
(...) Here's one that's MUCH better-- 'course most of you may have seen this already... someone made code equivalent to UNIX's wc command that can be compiled and run the exact same in perl and C... this one was really clever: (Grrr, it's gonna put (...) (24 years ago, 7-Sep-00, to lugnet.off-topic.geek)

19 Messages in This Thread:







Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR