Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!asuvax!ncar!csn!boulder!spot.Colorado.EDU!frechett From: frechett@spot.Colorado.EDU (-=Runaway Daemon=-) Newsgroups: comp.unix.questions Subject: Wanting to convert awk to perl Summary: Would perl be faster than awk... Keywords: awk, perl, csh Message-ID: <1991May19.064619.2493@colorado.edu> Date: 19 May 91 06:46:19 GMT References: <1991May19.034308.9149@cpsc.ucalgary.ca> <1991May19.060736.26323@ux1.cso.uiuc.edu> Sender: news@colorado.edu (The Daily Planet) Organization: University of Colorado, Boulder Lines: 56 Nntp-Posting-Host: spot.colorado.edu Some time ago I wrote a handy little script in csh that used an awk script as well to replace the "biff" that we have on our machines.. The built in biff is horrible as it blurts out about 4 lines and totally messes up my screen.. At 2400 baud, I simply don't want to waste the time redrawing the screen if I don't have to.. So I wrote a script that is in my .forward. It grabs username from the From: line of incoming mail then prints out MAIL from username wherever the cursor currently is, and then the cursor promptly returns to the M in MAIL. This of course means that it doesn't mess up my screen at all. Just recently I mangaged to get the csh script and the awk scripts all into one csh script. I like it in general, but I feel that it could be done faster in perl. I can get the various awk routines into perl easily enough but I get stuck trying to emulate other stuff.. I will include my script here and put current comments in double ##. #!/bin/csh # informe Written by Ian Frechette frechett@spot.coloraod.edu # set username to the name of the person who this is to output to... set username = frechett # find Username's ttys set ttys = (`find /dev -user $username -print`) ## Figuring out how to do find in perl is puzzling me... and I can't even ## get a system command into a varible that perl can recognize. # Extract address from incoming message. ## first awk routine.. The problems that I had with awk here, was that there is ## no way to pass a variable out of awk.. Thus the set address = `` nonsense. ## I would like to remedy that. set address = `awk '/^From:/ { test = 0 ;for(i = 1 ; i <= NF ; ++ i) { if ($i ~ /@/) { if ($i ~ /^ /dev/null # Make sure no errors are returned or mail will bounce. exit(0) I would like to know if any perl wizards out there would be interested in giving me some hints on what to do or demonstrating what needs to be changed... Any help at all would be appreciated, and comments regarding the script itself I might find interesting.. Thanks.. ian -=Runaway Daemon=- (UNIXOps University of Colorado at Boulder)