I added some duplicate records so you can see that indeed only the first of each duplicate record is printed.use strict; use Text::CSV; my $csv = Text::CSV->new (); my %unique_records; while (my $record = <DATA>) { $csv->parse($record) or die "Could not parse $record"; my @columns = $csv->fields(); s/.*=\s*(.*)/$1/ for @columns; print "$columns[0],$columns[1],$columns[4]\n" unless $unique_recor +ds{$columns[1]}++ ; } __DATA__ Id=1,DE RecName: Full=anahnata,DE RecName: Full=deals,DE RecName: Full +=buy, Type = cat Id=2,DE RecName: Full=hahhhhaa,DE RecName: Full=sure,DE RecName: Full= +sue, Type = dog Id=3,DE RecName: Full=anahnata,DE RecName: Full=deals,DE RecName: Full +=buy, Type = cat Id=4,DE RecName: Full=hihahiha,DE RecName: Full=sure,DE RecName: Full= +sue, Type = horse Id=5,DE RecName: Full=anahnata,DE RecName: Full=deals,DE RecName: Full +=buy, Type = cat Id=6,DE RecName: Full=hahhhhaa,DE RecName: Full=sure,DE RecName: Full= +sue, Type = dog
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In reply to Re: how to substitute next line with nothing
by CountZero
in thread how to substitute next line with nothing
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |