Purging Logs
Many programs maintain some variety of logs. Often, much of the information in the logs is redundant or just useless. The program shown in Listing 37.7 removes all lines from a file that contain a particular word or phrase, so lines that you know are not important can be purged. For example, you might want to remove all the lines in the Apache error log that originate with your test client machine because you know those error messages were produced during testing.
Listing 37.7. Purging Log Files
#!/usr/bin/perl# Be careful using this program!# This will remove all lines that contain a given word# Usage: remove <word> <file>$word=@ARGV[0];$file=@ARGV[1];if ($file) { # Open file for reading open (FILE, "$file") or die "Could not ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access