constantreader has asked for the wisdom of the Perl Monks concerning the following question:
Dearest Monks,
Does anyone know of a way to get Text::CSV_XS to ignore blank lines. Or at least allow me easily determine the line has no data. I'm using getline_hr and column_names to get a hashref. On a blank line (ie, /^$/), I still get a hashref with all the keys and undefs for values. Ideally, it would be nice if it returned an empty hashref.
The only way I have figured out how to do this is to get the line, regex it, and if it has data, then pass it to parse and then to fields. This seems rather inelegant.
Thanks
Update: I just realized the only way to get a hashref is to use getline_hr. fields only returns an array.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Text::CSV_XS and blank lines
by Jim (Curate) on Feb 03, 2011 at 22:18 UTC | |
by constantreader (Initiate) on Feb 03, 2011 at 22:29 UTC | |
by Jim (Curate) on Feb 03, 2011 at 22:39 UTC | |
by constantreader (Initiate) on Feb 03, 2011 at 22:46 UTC | |
by Tux (Canon) on Feb 04, 2011 at 07:11 UTC | |
|
Re: Text::CSV_XS and blank lines
by Tux (Canon) on Feb 04, 2011 at 07:09 UTC | |
by Jim (Curate) on Feb 04, 2011 at 17:11 UTC | |
by Tux (Canon) on Feb 04, 2011 at 18:51 UTC | |
by Jim (Curate) on Feb 04, 2011 at 19:18 UTC |