my ($help, $config_file, $component, $srcpath);
GetOptions(
- 'help' => \$help, # show help message and exit
- 'config=s' => \$config_file, # INI file for path mappings
- 'component=s' => \$component, # The component to grab the source paths for
- 'srcpath=s' => \$srcpath # The source path to grap the destination path for
+ 'help' => \$help, # show help message and exit
+ 'config=s' => \$config_file, # INI file for path mappings
+ 'component=s' => \$component, # The component to grab the source paths for
+ 'srcpath=s' => \$srcpath # The source path to grap the destination path for
);
if ($help) {
# load config
die "No config file specified\n" unless ($config_file);
die "Config file does not exist\n" unless (-r $config_file and -s $config_file);
+
my $cfg = new Config::Simple($config_file);
if (!$component) {
}
}
} elsif (!$srcpath) {
- foreach my $key (keys $cfg->get_block($component)) {
+ foreach my $key (keys %{$cfg->get_block($component)}) {
#again we use newlines because spaces can be used within directory names. I belive
#it is possible to use a newline in a directory name, but someone would have to be
#trying really hard to make things break if they started doing that with the Evergreen
print $key . "\n";
}
} else {
- print $cfg->get_block($component)->{$srcpath};
+ while (!defined $cfg->get_block($component)->{$srcpath}) {
+ $srcpath =~ s/\/[^\/]*$//;
+ if ($srcpath !~ '/') {
+ last;
+ }
+ }
+
+ if (defined $cfg->get_block($component)->{$srcpath}) {
+ print $cfg->get_block($component)->{$srcpath};
+ }
}