Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Filtering rows with Parse::CSV

by AppleFritter (Vicar)
on Mar 27, 2017 at 18:07 UTC ( [id://1186111]=note: print w/replies, xml ) Need Help??


in reply to Filtering rows with Parse::CSV

Off the top of my head and untested:

while (my $row = $parser->fetch()) { my $myColumn_value = $row->{'myColumn'}; print $myColumn_value unless($myColumn_value eq ""); }

if (and unless) can act as statement modifiers in Perl, so this will cause the print to be executed only if $myColumn_value isn't equal to the empty string.

You will get a warning here if it's undefined, BTW. If that's an issue, use

print $myColumn_value unless(($myColumn_value // "") eq "");

instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1186111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-18 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found