Andrew Dunstan <and...@dunslane.net> writes: > And here it is. No subclass, no eval, no magic :-) Some of my colleagues > are a lot happier ;-) > > The downside is that we need to litter PostgresNode with a bunch of > lines like: > > local %ENV = %ENV; > _set_install_env($self);
I think it would be even neater having a method that returns the desired environment and then have the other methods do: local %ENV = $self->_get_install_env(); The function could be something like this: sub _get_install_env { my $self = shift; my $inst = $self->{_install_path}; return %ENV unless $inst; my %install_env; if ($TestLib::windows_os) { # Windows picks up DLLs from the PATH rather than *LD_LIBRARY_PATH # choose the right path separator if ($Config{osname} eq 'MSWin32') { $install_env{PATH} = "$inst/bin;$inst/lib;$ENV{PATH}"; } else { $install_env{PATH} = "$inst/bin:$inst/lib:$ENV{PATH}"; } } else { my $dylib_name = $Config{osname} eq 'darwin' ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH"; $install_env{PATH} = "$inst/bin:$ENV{PATH}"; if (exists $ENV{$dylib_name}) { $install_env{$dylib_name} = "$inst/lib:$ENV{$dylib_name}"; } else { $install_env{$dylib_name} = "$inst/lib"; } } return (%ENV, %install_env); } - ilmari -- "A disappointingly low fraction of the human race is, at any given time, on fire." - Stig Sandbeck Mathisen