in reply to Re^2: Unable to read files from a directory
in thread Unable to read files from a directory
Using the file glob is a good idea, so now just fix the open statement:
BTW, I like proper indenting... don't you?#!/usr/bin/perl use strict; my @files = <C:/Perl/bin/Anti/*>; for my $file (@files) { my count = 0; open(MYFILE,"<",$file) or do { warn "Failed to open file: $file:$! +\n"; next}; while(<MYFILE>) { $count++; } print "$file has $count lines\n"; }
|
|---|