Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!dimacs.rutgers.edu!seismo!uunet!aspect!dave From: dave@aspect.UUCP (Dave Corcoran) Newsgroups: comp.lang.perl Subject: handy dandy cpp substitute using m4 & perl Keywords: cpp m4 perl Message-ID: <7683@aspect.UUCP> Date: 15 Feb 91 06:19:11 GMT Organization: Aspect Telecommunications, San Jose, Ca Lines: 37 printf("Hello world\n"); Here is a short m4 macro which may present some interesting possiblities: --------------------------8<------------------------- #definitions here define(`pe_', `syscmd(perl -e ' '` $@ ''` )') dumpdef(`pe_') define(cs_,`pe_(printf ("%2.2f,%2.2f",sin(cos($1)),cos($2));)') define(x,`pe_(print cos($1);)') #end definitions & begin invocations double x [] = {pe_( for $i (1..20) { $i=sqrt($i); $j=sqrt($i+20); $out=join(",",$out,$i,$j,log($i)); } ($out=~s/,//); # note the parens are need to overide the , # the m4 argument separator print $out; )}; double y [] = {cs_(1,4),x(22)}; --------------------------------------8<-------------------------- -- David Corcoran -@@ uunet!aspect!dave ~ In a society where anything goes eventually everything will.