in reply to Re^4: How to check lines that start with the same word then delete one of them
in thread How to check lines that start with the same word then delete one of them

That's because you have changed the criteria. 'S_FER_VENT1_ERRCOLINV;ERRORE PROFIBUS COLL INVERTER;ST;0;ST;1;0;TS;0;0' does not match the check in your initial post of

if($var eq $1 and $line2 =~ /(.*?);.*?;SU LI IR ST;.*?;SU LI IR ST;.*? +;.*?;.*?;.*?;.*?(?:$)/)

... so it has not been removed. Did you not mean this? Was your initial post misleading?