in reply to Re^2: replace all but first
in thread replace all but first

use strict; use warnings; my %seen; while ( <DATA> ) { next unless /^(<cnt>([^<]+)<\/cnt>)(.*)$/; print $seen{$2}++ ? "<TAB>$3\n" : "$1$3\n"; } __DATA__ <cnt>France</cnt><cmp>ACCOR</cmp> <cnt>France</cnt><cmp>AGF</cmp> <cnt>France</cnt><cmp>AIR LIQUIDE</cmp> <cnt>Germany</cnt><cmp>ALLIANZ INSURANCE</cmp> <cnt>Germany</cnt><cmp>ALLIANZ PARKWAY</cmp> <cnt>Germany</cnt><cmp>ALLIED DOMECQ</cmp> <cnt>United Kingdom</cnt><cmp>LEICESTER CITY FOOTBALL CLUB</cmp> <cnt>United Kingdom</cnt><cmp>SPENCER GEARS</cmp>