in reply to Regular Expression

foreach (@recs) { $found{$1}++ while /\s-D(\S+)/g; } print "Found flags: ", join(" ", sort keys %found), "\n";
Hashes are great for keeping track of unique values.