foreach (@vals) { $SubKey->GetValues(\%cvalues); if ($cvalues{'Server'}[2] =~ NT-PRINT1) {print "something\n"}; elsif ($cvalues{'Server'}[2] =~ NT-PRINT2) {print "another thing\n"}; }