I want to delete those .txt files in a folder that has <=3 of ">" character (starts as header). As a beginner in perl scripting, I have used:
use strict; use warnings; while ( my $file = glob '*.txt' ) { open my $fh, '<', $file; my $headers = grep /^>/, <$fh>; if ($headers <= 3) { unlink $file; } }
After executing it won't delete any files and won't show any errors either.
What am I doing wrong?
In reply to Whats wrong in this code? by abhikalrt53
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |