while(){ $line = $_; if ($line =~ m/^update\ (\w*)[^\s]/){ print $1."\n"; } }