package My::Package::Foo; sub handler { my($r) = shift; my($file) = $r->dir_config('FooConfig'); open(CONF,$file) || die("$!: $file"); while() { ... same code for parsing stuff as before ... } close(CONF); ... more code for doing other stuff ... }