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


in reply to lolhackedlol

You have changed the code in your original post. Please don't do that as it renders some of the previous answers non-sensical and prevents readers of the whole thread in future from understanding it. Have a read of How do I change/delete my post? particularly the section headed It is uncool to update a node in a way that renders replies confusing or meaningless.

Your newer code works as it stands (albeit that one might have written it somewhat differently). If it is printing every line from the log, that will be because every line in the log matches. You can confirm this yourself using the system grep:

grep -f /home/user/Desktop/keywords /var/log/syslog

If you have a colourising system grep this will make it very clear where the matches are occurring.