Try something like open (PIPE, "awk '{print $1}' somefile");
and just run the perl script. -Michael >>> Bryan Harris <[EMAIL PROTECTED]> 02/21/03 02:41PM >>> I'm writing a simple script (qstat) to sum, count, and average whatever stream of numbers the user throws at it. It loops through @ARGV reading files, so it works fine if I say: qstat somefile someotherfile However I'd like to be able to do: awk '{print $1}' somefile | qstat This doesn't work. How do I accept input from a pipe? TIA. - Bryan ps. Here's the script, in case that helps: #!/usr/bin/perl -w # # qstat, v0.1 # by Bryan Harris, 2/21/03 # # This script provides simple statistics # about all the numbers in the provided files # # Much handier if used in conjunction with # awk # check for sufficient command line inputs #if ($#ARGV < 0) { # print "Usage: qstat <list of files>\n"; # exit(0); } $sum = 0; $count = 0; $max = -1e24; $min = 1e24; undef $/; # loop through files foreach $file (@ARGV) { open(FILE, $file) || die("Couldn't open $file: $!\n"); $_ = <FILE>; close(FILE); @nums = split; foreach (@nums) { if (/^[\d\.\-\+]/) { $sum += $_; $count++; ($_ > $max) && ($max = $_); ($_ < $min) && ($min = $_); } } } if ($count) { $avg = $sum/$count; $range = $max - $min; print "sum\tcount\trange\tmin\tmax\tavg\n$sum\t$count\t$range\t$min\t$max\t$avg\n"; } exit(0); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]