open (my $file, '<', 'formation.txt') || die "Error opening file: $!"; while (<$file>) { chomp; # removes trailing newline character print "Line contents: $_\n"; }