Xref: feenix.metronet.com alt.hackers:1685 Newsgroups: alt.hackers Path: feenix.metronet.com!news.utdallas.edu!convex!convex!convex!cs.utexas.edu!math.ohio-state.edu!caen!hellgate.utah.edu!asylum.cs.utah.edu!galt From: galt%asylum.cs.utah.edu@cs.utah.edu (Greg Alt) Subject: my first perl hack Date: 13 Oct 93 03:16:58 MDT Message-ID: <1993Oct13.031659.27213@hellgate.utah.edu> Followup-To: alt.hackers Sender: galt@asylum.cs.utah.edu (Greg Alt) Organization: University of Utah Computer Science Approved: Sure, why the hell not. Lines: 12 I kept hearing about perl, and it sounded interesting, so I finally got around to trying it out. Here's my first perl program: #!/usr/bin/perl if(@ARGV){$w=int(shift(@ARGV)/2)*2+1;$h=int(shift(@ARGV)/2)*2+1;}else{$w=81 ;$h=25;}$m=' 'x$w.(' '.'#'x($w-2)." ")x($h-2).' 'x$w;main:for(substr($m,$p= 2*$w+2,1)=4;$v!=4;){$o=$v=int(rand(4));do{substr($m,$p+$d,1)=' ',substr($m, $p+=2*$d,1)=$v,next main if(substr($m,$p+2*($d=((($v&2)?1:-1)*(($v&1)?1:$w) )),1)eq'#')}while($o!=($v=($v+1)%4));$v=substr($m,$p,1);substr($m,$p,1)=' ' ;$p-=2*((($v&2)?1:-1)*(($v&1)?1:$w)) if ($v<4);}for($i=0;$i<$w*($h-2);print substr($m,1+($i+=$w),$w-1),"\n"){}