6 # Check arguments and print help function if needed
8 print "Usage: $0 NAME=SOURCE [NAME=SOURCE] ... OUTPUTHEAD\n\n";
9 print "NAME Name of the string variable to create in the header\n";
10 print "SOURCE Source file(s) that you would like to analyze\n";
11 print "OUTPUTHEAD Place where you would like to put the output header\n";
12 return "\nYou did something wrong with arguments\n";
15 # Check presence of arguments
16 my $out_file = pop @ARGV or die print_use;
21 # Check that each source file exists
23 foreach my $arg (@ARGV) {
24 my @holder = split(/=/, $arg);
26 if (not -e $holder[1]) {
27 print "File $holder[1] does not exist!\n\n";
31 $out_vars{$holder[0]} = $holder[1];
34 # Check first line of header
36 open (my $handle, '<', $out_file);
37 chomp (my $first = <$handle>);
39 if ($first ne '#ifndef CROMBIE_BCALSTRINGS_H') {
40 print "First line of $out_file looks suspicious! I don't want to overwrite:\n";
48 open (my $out, '>', $out_file);
51 #ifndef CROMBIE_BCALSTRINGS_H
52 #define CROMBIE_BCALSTRINGS_H 1
56 namespace bcalstrings {
59 while ((my $varname, my $csvfile) = each(%out_vars)) {
60 print $out "\n const std::string $varname = \"\"\n";
61 open(my $input, '<', $csvfile);
66 print $out " \"$_\\n\"\n";