Help for this page

Select Code to Download


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