Subject: | An interface to skip non-existing or non-readable includes (fine control/tuning) |
Hi,
I'd like to be able to do this[1] to skip some random number of included files.
Basically we can have lets say 10 includes in a conf file and some of them might
suddenly disappear by some automated tool failure or sysadmin error. But 80% of the code
can run in some degraded mode without (lets say) half of the files present.
I'm not so sure about the interface but perhaps it can be something like:
if ( $this->{missing_include_handler}
&& defined $this->{missing_include_handler}->( $configfile ) # can also die() or whatever
# or make this $this->missing_include_handler which can be overridden by a subclass
) {
return;
}
# fall back to the default: die()
Additionally, if the call to actual open (CORE::open) can be hidden in a single method as well,
it'll be good to have that over ridable. Currently the calls to open are not limited to a single
abstracted call (I'd like to have this to be able to detect the file modes and ignore them if they
exist but not readable and lets say $IGNORABLE{ $file } is true).
Thanks,
Burak
----------[1]------------
[burak@foo Config]$ diff -uNa General.pm.orig General.pm
--- General.pm.orig 2012-09-17 17:36:08.000000000 +0200
+++ General.pm 2012-09-17 17:38:29.000000000 +0200
@@ -462,6 +462,10 @@
}
}
if (!$found) {
+ if ( $configfile =~ m{foobar[.]conf$} ) {
+ warn "oooh! nooooes! -> $configfile\n";
+ return;
+ }
my $path_message = defined $this->{ConfigPath} ? q( within ConfigPath: ) . join(q(.), @
{$this->{ConfigPath}}) : q();
croak qq{Config::General The file "$basefile" does not exist$path_message!};
}