Perl script to print multi line log entries which has a match for given pattern
The code definitely isn't bad. I'd still use strict and warnings, though. Minor remarks:


Why do you use " for qr? / or {} are canonical.
$_ is good for short loops, and its advantage is you don't have to type it. So, I'd name the main loop's variable, as its scope is rather wide.
Avoid deep indentation. Use subroutines.
defined @fh is deprecated.


My version:

#!/usr/bin/env perl
use warnings;
use strict;

use Term::ANSIColor;

my $pattern = qr/[.a-zA-Z0-9]*Exception/;


sub output {
    my @buffer = @_;
    my $hilight = 'black on_yellow';
    for (@buffer) {
        if (my ($matched) = /($pattern)/) {
            for (split /($pattern)/) {
                print $_ eq $matched ? colored($matched, $hilight) : $_;
            }
        } else {
            print;
        }
    }
}


my $begin   = qr/^\d\d:\d\d/;

my ($found, @buffer);
open my $fh, '&lt;', $ARGV[0] or die "Could not open file '$ARGV[0]' $!";
while (my $line = &lt;$fh&gt;) {
    if ($line =~ /($begin)/) {
        output(@buffer) if @buffer &amp;&amp; $found;
        @buffer = ();
        undef $found;
    }
    push @buffer, $line;
    $found = 1 if $line =~ /$pattern/;
}

# Output the last match if it ends with an EOF instead of a timestamp.
output(@buffer) if @buffer &amp;&amp; $found;