while ($line=) { @temp = split(/[=]/,$line); if ($temp[1] >100) { print "Session id: $temp[1] "; $sessid = $temp[1]; } #I want the following to run only if $sessid changes $modtyp = $temp[1]; if($modtyp == 20) { print " V34\n\n "; } elsif ($modtyp == 9) { print " no connection\n\n"; }