in reply to Motherboard Temperature
In this case we assumed that the temperatures matched the expression \d+ (1 or more digits). A slightly more sophisticated expression is needed to match floating point data.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.
-M
Free your mind
|
|---|