Hi, [EMAIL PROTECTED] asked: > How do I parse or evaluate the output of UNIX commands? > > For example, in UNIX scripts, I can run filesystem=`df -k | > awk -F"" ' { print > $6 }'` to check for the mount points. > > How do I achieve the same in Perl? That is, I tried:
Essentially in the same way - i.e. "my $x = `df -k`". > Maybe I can just simply run system 'df -k', re-direct that > into some output file and then parse it using OPEN-CLOSE > filehandles. Is there any easier way of doing this? Yes, like this: open( FH, '-|', 'df -k' ) or die "error: $!"; while( my $line = <FH> ){ # parse df output here } close( FH ) or die "error: $!"; I really recommend that you read the sections about open() in the perlipc manpage. Lots of good stuff there! HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>