#!/usr/bin/perl open HELP, '<', "help.orig" || die "Can't open help"; my $cur_metric; my $short_text; my $long_text; my %help = (); while () { my $line = $_; if ($line =~ /^#.*/ ){ #comment next; } elsif ($line =~ /^\s*$/ ) {# skip blanks next; } elsif ( $line =~ /^\@ (\S*) (.*)$/ ){ $cur_metric = $1; $short_text = $2; $cur_metric =~ s/^proc\.//; # remove leading proc. $short_text =~ s/"//g; # get rid of any quotes, hackish $help{$cur_metric}={}; $help{$cur_metric}->{'name'}=$cur_metric; $help{$cur_metric}->{'short'}=$short_text; } else { # should be all long text now $long_text = $line; $long_text =~ s/"//g; # get rid of any quotes, hackish chomp($long_text); $help{$cur_metric}->{'long'} = $help{$cur_metric}->{'long'} . $long_text ."\\n"; } } print "typedef struct {\nchar *name;\nchar *shorthelp;\nchar *longhelp;\n} help_text_t;\n"; print "help_text_t help_text[] = {\n"; foreach my $key (keys %help){ my $name = $help{$key}->{'name'}; my $short = $help{$key}->{'short'}; my $long = $help{$key}->{'long'}; print "{ .name = \"$name\", .shorthelp = \"$short\", .longhelp = \"$long\" },\n"; } print "};";