> "Shawn" <[EMAIL PROTECTED]> said:

> #!/usr/bin/perl -w
> 
> use strict;
> open(IN, 'who | ');
> my @array=<IN>;
> close(IN);
> 
> open(FILE,'>file.txt') or die "Can't write file.txt: $!\n";
> print FILE @array;
> close(FILE);

Or the line at a time case when your input is potentially arbitrarily sized:

open(IN, "who |");
open(FILE, ">file.txt");
while (<IN>) {
        print FILE;
}
close IN;
close FILE;

This, of course,  is equivalent to:

who >file.txt

in the Unix shell.
-- 
Smoot Carl-Mitchell
Consultant




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to