http://www.perlmonks.org?node_id=993579


in reply to Looking for a string from a huge log file

Not my intention to be rude, but delete this script, think a little in what do you want to do and try again. Seriously, is very poor.

For example: You claim to have a big file, Well, you are chomping each same line of this huge file up to three times. So your script is very bussy... doing nothing. If you need to delete a special input separator redefine $/

Don't apply four lines of regex if you want to delete a line containing "my pattern". Use "grep-not" (grep !/my pattern/, FH) instead.

keeps on printing the same string for all the other ID's

because $_ is not changing at all in the last lines. The loop has finished when you print to outfile so you only have the last matched line of your log in $_.

can you explain a little what do you need to do?

while(<MYINPUTFIL3>){

Try to keep it simple and readable, filehandles don't need to be complicated:

while(<LOG>){