package MJD::Print; use Exporter; @ISA = 'Exporter'; @EXPORT_OK = qw(load_conf); # my $CONFIG = '/etc/printd.conf'; my $CONFIG = $/home/mjd/src/perl/lps/printd.conf"; sub load_conf { my $file = shift; my $last_mod_time = (stat $file)[7]; unless (defined $last_mod_time) { die "Couldn't stat config file $file: $!; aborting"; } return if $last_mod_time < $CONF_LAST_READ; local $_; # Note that *CONF is GLOBAL because it will hold the file lock open CONF, $file or die "Couldn't read config file $file: $!; aborting"; unless (flock CONF, LOCK_EX|LOCK_NB) { exit 0 if $! == EWOULDBLOCK; temp_error("Couldn't lock config file: $!; aborting", 60); } my %C; while () { s/#.*//; next unless /\S/; chomp; my ($attr, $val) = split /\s+/, $_, 2; $C{$attr} = $val; } return %C; } 1;