The above can work, but if the file is huge, we might not be able to hold all the list in memory. Change the read_file function that to allow the user to supply the analyze function (or rather the reference to the analyze function) as a paramter. See the skeleton below. The output should be the same as above.

examples/references/dna2_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";
    }
}

sub read_file {
    ...
    return;
}