Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: validating file with perl

by si_lence (Deacon)
on Jul 17, 2013 at 12:26 UTC ( #1044797=note: print w/ replies, xml ) Need Help??


in reply to validating file with perl

Just one more solution using the input record separator special variable ,$/. It does make a few assumption about the structure of the data though.

use strict; use warnings; my $header = <DATA>; $/ = "\n\n"; while (<DATA>) { if (/ 1\n.* 3\n/s) { my $id = substr($_,0,11); print "good for $id\n"; } } __DATA__ field1 field2 3-2000/7.48 1 3-2000/7.48 2 3-2000/7.48 2 3-2000/7.48 2 3-2000/7.48 2 3-2000/7.48 2 3-2000/7.48 2 3-2000/7.48 3 4-0000/8.40 2 4-0000/8.40 2 4-0000/8.40 2 4-0000/8.40 2 4-0000/8.40 2 4-0000/8.40 2 4-0000/8.40 3


Comment on Re: validating file with perl
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2015-08-01 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls