The fact that these number are date/time values makes no difference. They are integers (albeit rather large ones) and they can be compared in exactly the same way as any other integer.
while (<$your_input_filehandle>) {
# I have no idea of the format of your input data, so I can't
# begin to implement extract_timestamp()
my $this_records_timestamp = extract_timestamp($_);
if ($this_records_timestamp >= $min_timestamp and
$this_records_timestamp <= $max_timestamp) {
# timestamp is within the given range
}
}
Update: To convert YYYYMMDD to YYYYJJ
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Time::Piece;
my $in_format = '%Y%m%d';
my $out_format = '%Y%j';
my $in_date = shift
|| die "Please pass date in format YYYYMMDD\n";
my $date = Time::Piece->strptime($in_date, $in_format);
say $date->strftime($out_format);