#!/usr/bin/perl use warnings; use strict; use 5.10.0; open my $fh, '<', 'data.txt' or die $!; my $begin = 0; while ( my $line = <$fh> ){ chomp $line; $begin = 1 if $line =~ /0x014E/; next unless $begin; say $line and last if $line =~ /^Output:/; }