use strict; use warnings; use POSIX ":sys_wait_h"; my $pid = open my $filehandle, "| speedfan"; # or whatever command it is my ($ltemp, $rtemp, $hdo); while( <$filehandle> ) { #reads the line into predeclared $_ # per line loop of output e.g. ... /^Local Temp:\s(\d+)C/ and $ltemp = $1 and next; /^Remote Temp:\s(\d+)C/ and $rtemp = $1 and next; /^HDO:\s(\d+)C/ and $hdo = $1; } close $filehandle; waitpid $pid,0; # wait for subprocess to terminate # $ltemp, $rtemp and $hdo now contain the temperatures.