#!/usr/bin/perl -w use strict; my $start_copy = 0; while (<>) { next if /^\s+$/; if ((!$start_copy) and (/^# Time: (\d+)\s+(\d+):(\d\d):(\d\d)/)) { my $date = $1; my $hour = $2; # check if date and time are what you need if ((substr($1,4,2) eq "06") and ($hour gt "09")) { $start_copy = 1; } } print if $start_copy; }