Is this homework? If so that's fine but you should indicate it, and get started on the problem yourself. The monks will be happy to help you if you get stuck. Loops just gave you a nice terse solution but how would you explain it to a teacher or professor if she asked?
As a starting point, this is a pretty standard way in Perl to open a file for reading and iterate over its contents line by line:
open (my $file, '<', 'formation.txt') || die "Error opening file: $!";
while (<$file>) {
chomp; # removes trailing newline character
print "Line contents: $_\n";
}
If you want to store the lines of a file in an array, you can use
push (actually, there are much shorter ways to "slurp" the contents of a file into an array, but this works fine):
my @lines;
open (my $file, '<', 'formation.txt') || die "Error opening file: $!";
while (<$file>) {
chomp; # removes trailing newline character
push @lines, $_;
}