in reply to Format multiline to single line records
#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; my $text = do {local $/;<DATA>}; $text =~ s/\n(?!\d{7})/ /g; # Remove newline if no # new record my %records = map { split /\s+/, $_ , 2 } split /\n/, $text; print Dumper(\%records) __DATA__ 1000001 01.11.199600.00.00001 A1 1 SN Y 2001.11.200400098.0500073.5500083.35 5001.11.1997Professional attendance being an attendance at 5001.11.1997other than consulting rooms 1000002 01.11.199600.00.00001 A1 1 SN Y 2001.11.200400098.0500073.5500083.35 5001.11.1997Professional attendance being an attendance at 5001.11.1997consulting rooms
Hope it helps,
deibyz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Format multiline to single line records
by kerrya (Novice) on Oct 19, 2004 at 22:09 UTC |