What if you would like to provide the user the ability to stop the processing any time she wants even if the file has not finished yet? For example when she found the first match. This can be controlled by the return value of the analyze function. If it is true, stop processing. See the skeleton and the expected output:

examples/references/dna3_skeleton.pl
#!/usr/bin/perl
use strict;
use warnings;

my $file = 'dna.txt';

my @dna_sequences = read_file(\&analyze_dna, $file);
sub analyze_dna {
    my ($dna) = @_;
    if ($dna =~ /(.)\1/) {
        print "$dna has double $1\n";
        return 1
    }

    return 0;
}

sub read_file {
    ...
    return;
}
examples/references/dna3.out
GAGATTC has double T