use Fcntl qw(SEEK_SET); my $input = '...'; my $start = 1_490_117; my $end = 1_492_312; my $length = $end - $start +1; open my $fh, '<', $input or die "Can't open $input: $!"; sysseek($fh, $start, SEEK_SET) or die "Can't seek to $start in $input: $!"; my $sequence; my $read = sysread $fh, $sequence, $length; die "Failed to read $length bytes from $input, got $read" if $length != $read;