#!/usr/bin/perl use strict; use warnings; my $pfx = shift || ''; # typical input: # 1 OPTION_CLIENTID [RFC3315] while (<>) { my ($code, $name, $ref, $rest) = split(/\s/); if ($rest || !$ref) { # i.e. parse failure chomp; print "/* $_ */\n"; next; } $name =~ s/-/_/g; print "#define $name\t\t$code\t/* $ref */\n"; }