my $calog = "/var/log/ca/ca.log.1"; my @newlist; @calines = get_file($calog); @newlist = which_lines(@calines); print "@newlist"; ############################# # Important part ############################# sub which_lines { for (@_) { /\.512/ && do { push(@new1, $_);}; } for (@new1) { !/renewed|revoked/ && do { push(@new, $_); }; } return @new ; } sub get_file { my $file = shift; local *IN; open (IN, "<$file") or die "Cannot read '$file': $!"; if (wantarray) { return ; } else { return join '', ; } }