summaryrefslogtreecommitdiffstats
path: root/long-lines.pl
diff options
context:
space:
mode:
Diffstat (limited to 'long-lines.pl')
-rwxr-xr-xlong-lines.pl7
1 files changed, 5 insertions, 2 deletions
diff --git a/long-lines.pl b/long-lines.pl
index c0e1da0..f0a117f 100755
--- a/long-lines.pl
+++ b/long-lines.pl
@@ -4,6 +4,7 @@ use strict;
use File::Basename;
use Getopt::Std;
use Text::Tabs;
+use Carp;
my %opt;
getopts("hm:t:", \%opt);
@@ -25,13 +26,15 @@ $max = $opt{m} if ($opt{m});
$Text::Tabs::tabstop = $opt{t} if ($opt{t});
for my $file (@ARGV) {
- open FILE,"<", $file;
+ open my $fh,"<", $file or do {carp "Failed to open $file: $!"; next;};
+
$line = 0;
- while (<FILE>) {
+ while (<$fh>) {
$line++;
$_ = expand $_;
if (length > $max) {
print "\"$file\" - line $line: ", length, " chars\n";
}
}
+ close $fh;
}