What are best practices for working with reading files (<> diamond operator)?

Perl, diamond operator, file handling
Best practices for reading files in Perl using the diamond operator, including error handling and line processing.
#!/usr/bin/perl use strict; use warnings; # Enable autodie for automatic error handling use autodie; # Open a file for reading my $filename = 'example.txt'; open my $fh, '<', $filename; # Process each line in the file while (my $line = <$fh>) { chomp $line; # Remove the newline character print "$line\n"; # Do something with the line } close $fh; # Close the filehandle

Perl diamond operator file handling