4 use File::Slurp qw(slurp);
6 die "usage: $0 <input_file>" unless @ARGV;
8 die "file not found: $file\n" unless -f $file;
9 die "open failed: $file\n" unless open IN, "<$file";
11 my $input = slurp(\*IN);
13 my ($before, $gupcr_cfg, $after) =
14 ($input =~ m{(.*//begin\ gupcr_config_h\n)(.*)
15 (//end\ gupcr_config_h.*)}xs);
17 die "could not match the gupcr_config_h file markers\n"
18 unless defined($before)
19 && defined($gupcr_cfg)
22 $gupcr_cfg =~ s{^/\*\s*((?:(?!/\*).)*?)\s*?\*/\n
23 \#(?:define|undef)\s+(\w+)(.*?)$}
24 {/**\ \@brief\ ${1}\ */\n\#define\ ${2}${3}}xgms;
26 my $result = $before . $gupcr_cfg . $after;