in reply to Deleting a matching string in an array

You keep on declaring and initializing lexical filehandles, but never use them!

my $fh= new FileHandle; open(LOG, "<$log_file") or die "Could not open file";

You should decide. Either the oldstyle filehandles or the lexical ones. Also it's not needed to precreate the filehandles with new FileHandle, just use

open(my $LOG, "<$log_file") or die "Could not open file"; @logmessages=<$LOG>; close($LOG);
and if you do not use a perl that's more than 5 (or something like that) years old you will be just fine.