# this contains the hash %global_conf use GlobalConf; $headerfile = "global_conf.h"; open HEAD, ">$headerfile" or die "could not write header file\n$!"; # Intro print HEAD "/* global configuration for the XXXX project\n", " * automatically generated with pm2h from GlobalConf.pm \n */\n\n"; print HEAD "# ifndef GLOBAL_CONF_HH_INCLUDED\n", "# define GLOBAL_CONF_HH_INCLUDED\n\n"; recurse_hash(\%global_conf,"global_conf",0); print HEAD "\n# endif\n"; close HEAD; exit 0; # recursively traverse the hash sub recurse_hash { my ($hashref,$string_so_far,$depth) = @_; my $indent = " " x $depth; my $string = $string_so_far; my %hash = %{ $hashref }; foreach $key (keys %hash) { if (ref($hash{$key})) { recurse_hash($hash{$key},$string."_$key",$depth+1); } else { print HEAD "static char ",$string."_$key","[] = \"$hash{$key}\";\n"; # for debug #print $indent,$string."_$key","[] = \"$hash{$key}\";\n"; } } }