X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FGetopt.pm;fp=lib%2FMooseX%2FGetopt.pm;h=6c1100ceaa980deab4d3d97d09acdd8ef0227ba8;hb=2c379a5cff8517fd7710698d9177c589bbe899b3;hp=0321f620d707b40c9461d500404109fa7d123afe;hpb=801feb9772f98cd5ecd89440c2ddec4e2012ad54;p=gitmo%2FMooseX-Getopt.git diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 0321f62..6c1100c 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -31,9 +31,16 @@ sub new_with_options { if(!defined $configfile) { my $cfmeta = $class->meta->find_attribute_by_name('configfile'); $configfile = $cfmeta->default if $cfmeta->has_default; + if (defined $configfile) { + $config_from_file = eval { + $class->get_config_from_file($configfile); + }; + if ($@) { + die $@ unless $@ =~ /Specified configfile '\Q$configfile\E' does not exist/; + } + } } - - if(defined $configfile) { + else { $config_from_file = $class->get_config_from_file($configfile); } }