#!/usr/bin/perl open(MYFILE, "log.log"); while (){ s/\s+$//; if (/Message\sdump:/) { my $nextLine = ; $nextLine =~ s/\s+$//; print "Found=$nextLine\n"; # do stuff with the next line here. } }