Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: testing files for valid content

by lostjimmy (Chaplain)
on Apr 23, 2009 at 17:34 UTC ( [id://759599]=note: print w/replies, xml ) Need Help??


in reply to testing files for valid content

I would like to modify this file so that it checks for a full record or not

What denotes a full record? I'm assuming a record with nine columns. So all you have to do (unless you use a CSV module) is split the line and make sure it has nine values.

while (<FILE>) { chomp; my @values = split /,/; next if @values != 9; my($timeoftest, $login, $searchload, $searchresults, $searchdetails, $addlisting, $editlisting, $logout, $sitecode) = @values; # print the stuff like before }

Replies are listed 'Best First'.
Re^2: testing files for valid content
by chromatic (Archbishop) on Apr 23, 2009 at 18:44 UTC
    So all you have to do (unless you use a CSV module) is split the line and make sure it has nine values.

    Be careful. That works until a column has embedded (presumably quoted or otherwise escaped) commas. If splitting on commas always worked, there'd be little need for a module.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-29 15:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found