in reply to How check whether csv file with header is empty file or not in perl
This will say "Empty file" if the file only contains a header line plus optionally empty lines or lines with nothing but whitespace and comma's.use Modern::Perl; say 'Empty file' if 1 == scalar grep {/[^\s,]/} <DATA>; __DATA__ header1, header2, header3 ,,,,,,, , , , , , ,
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How check whether csv file with header is empty file or not in perl
by hi123 (Initiate) on Sep 06, 2012 at 11:07 UTC | |
by CountZero (Bishop) on Sep 06, 2012 at 14:42 UTC |