sub regexec { my $computer = shift; my $outkey = ""; my $key = `reg query \\\\\\\\$computer\\\\HKLM\\\\Software\\\\Microsoft\\\\Windows\\\ Nt\\\\CurrentVersion /v DigitalProductID 2>&1`; foreach (split(/\n/,$key)) { if (m/\s+DigitalProductID\s+REG_BINARY\s+([A-F0-9]+)/) { $_ = $1; s/([A-F0-9][A-F0-9])/$1,/g; $outkey = $_; } } return $outkey; }