@array=(1,2,3,4,5); foreach $element (@array){ chomp $element; if ($element == 1){ ##do something; } }