#!/usr/bin/perl my ($pos, %equipids); $pos = 0; while (<>) { while (s/^(\s*#\s*define\s+STR_(EQUIPID_[A-Z_]+)\s+(.*))$//) { next if defined($equipids{$2}); print "$1\n"; $equipids{$2} = $pos; $pos++; } } while (($key, $value) = each %equipids) { print "#define $key $value\n"; } print "#define EQUIPID_LAST $pos\n"; open(HANDLE, ">equipid.qc"); print HANDLE <