in reply to Break perl foreach loop
$x != "Patient" is wrong. If you want to test string inequality use ne.