7 my ($help, $config_file, $component, $srcpath);
10 'help' => \$help, # show help message and exit
11 'config=s' => \$config_file, # INI file for path mappings
12 'component=s' => \$component, # The component to grab the source paths for
13 'srcpath=s' => \$srcpath # The source path to grap the destination path for
21 Show help message and exit.
23 Location of INI file for path mappings.
25 The component of the INI file for which you want the paths.
26 If you do not specify a component value then all components
27 (sections) in the INI file are returned.
29 The source path to return the destination path for
36 die "No config file specified\n" unless ($config_file);
37 die "Config file does not exist\n" unless (-r $config_file and -s $config_file);
38 my $cfg = new Config::Simple($config_file);
42 #pull out components from INI file
43 open my $fh, '<', $config_file;
46 if ($_ =~ /^\[[^]]+\]$/) {
49 #we use newlines because spaces seem to be valid within an INI file section.
50 #I am not sure if newlines are also valid because I could not find anything
51 #defining the INI section syntax, but I imagine using a newline within an INI
52 #file section declartion is not done very often if it is valid syntax.
57 foreach my $key (keys $cfg->get_block($component)) {
58 #again we use newlines because spaces can be used within directory names. I belive
59 #it is possible to use a newline in a directory name, but someone would have to be
60 #trying really hard to make things break if they started doing that with the Evergreen
65 while (!defined $cfg->get_block($component)->{$srcpath}) {
66 $srcpath =~ s/\/[^\/]*$//;
67 if ($srcpath !~ '/') {
72 if (defined $cfg->get_block($component)->{$srcpath}) {
73 print $cfg->get_block($component)->{$srcpath};