Assuming that the first found product entry is valid (is it?), i would do it like this:
Update: I don't know how often i posted this wrong/useless M$dog shebop/shebang... #!/c:/perl/bin/perl.exe
#!c:/perl/bin/perl.exe use strict; use warnings; $/ = ""; my $file = shift; open my $fh, "<", $file || die $!; my @records = <$fh>; close $fh; my %records; for (@records) { $_ =~ m/(Product \d+)(.+)/s; my $product_id = $1; next if exists $records{$product_id}; $records{"$product_id"} = $2; } for (sort keys %records) { print qq($_ $records{$_}); } __END__ Product 1 ------------------------------------------------------------------ storeId = 1001 phoneNumber = (111) 111-1111 availbilityCode = 1 stockStatus = Limited stock distance = 9.12 city = some city fullStreet = some address Product 2 ------------------------------------------------------------------ storeId = 2117 phoneNumber = (111) 111-1111 availbilityCode = 2 stockStatus = In stock distance = 7.49 city = some city fullStreet = some address Product 3 ------------------------------------------------------------------ storeId = 2123 phoneNumber = (111) 111-1111 availbilityCode = 1 stockStatus = Limited stock distance = 8.83 city = some city fullStreet = some address
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
In reply to Re: Removing Duplicates from a multiline entry
by karlgoethebier
in thread Removing Duplicates from a multiline entry
by diamondsandperls
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |