in reply to Whats wrong in this code?
What am I doing wrong?
That's just 4 possibilities and you won't know which is the real problem until you add some diagnostics to your script. eg (untested):
use strict; use warnings; while ( my $file = glob '*.txt' ) { print "Debug: found file $file\n"; open my $fh, '<', $file or die "Cannot open file $file: $!"; my $headers = grep /^>/, <$fh>; if ($headers <= 3) { unlink $file or die "Cannot unlink file $file: $!"; } else { print "Debug: file $file only has $headers headers - skipping\ +n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Whats wrong in this code?
by abhikalrt53 (Novice) on Nov 19, 2016 at 06:35 UTC | |
by Athanasius (Archbishop) on Nov 19, 2016 at 06:55 UTC |