or die "On opening $words for reading: $!"; while (defined($line = <FH>)) { chomp $line; # strip trailing newline print "$line\n" if length($line) > 15; } close FH;
open (OUT, "> long-words.txt") or die; while (<IN>) { chomp; print OUT "$_\n" if length > 15; } close IN; close OUT or die "On closing file handle after writing: $!";
one of a few dozen different characters. For example: -e File exists -d File is a directory -z File has zero size (is empty) -t Filehandle is opened to a tty -M Get time since modification of file, in days See perldoc perlfunc for more
the strict pragma my $value = 1 + 2; # <-- now vars have to be declared with `my` print $Value; On running this: Global symbol "$Value" requires explicit package name at test.pl line 4. Execution of test.pl aborted due to compilation errors.