in reply to validating file with perl
Something like this:
use strict; use warnings; my %data; <DATA>; while(<DATA>){ chomp; next if/^\s*$/; my ($key, $value) = split; push @{$data{$key}},$value; } my $counter; for(keys %data){ for(@{$data{$_}}){ ++$counter if $_ == 1 or $_ == 3; } print $_,' a good file',$/ if $counter == 2; } __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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: validating file with perl
by Cristoforo (Curate) on Jul 16, 2013 at 22:47 UTC |