in reply to Re^2: identifying null fields in bar delimited records
in thread identifying null fields in bar delimited records
output:#!/usr/bin/perl use strict; use warnings; my %null; while (<DATA>){ my @fields = split(/\|/); for my $i (0..$#fields){ $null{"field$i"}++ unless $fields[$i]; } } for my $key (sort keys %null){ print "$key->$null{$key}\n"; } __DATA__ first||third|| alpha|beta||delta| ||c|d| one|||four|
The field numbers start at zero but also the second field has 3 compared to 2 in your desired ouput.field0->1 field1->3 field2->2 field3->1
The third line of your data starts with two bars, isn't that 2 null fields?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: identifying null fields in bar delimited records
by graff (Chancellor) on Jun 01, 2005 at 04:39 UTC |