savevars
view release on metacpan or search on metacpan
savevars.pm view on Meta::CPAN
my $cpt = new Safe;
$cpt->permit(qw(:base_core));
$cpt->share_from($callpack, \@imports);
$cpt->rdo($cfgfile);
}
}
sub cfgfile {
if (!defined $cfgfile) {
my $basename = ($0 =~ m|([^/\\]+)$| ? $1 : $0);
$cfgfile = eval { (getpwuid($<))[7] } || $ENV{'HOME'} || '';
if ($cfgfile eq '' && $^O eq 'MSWin32') {
$cfgfile = 'C:';
}
$cfgfile .= "/.${basename}rc";
}
$cfgfile;
}
sub writecfg {
my $cfgfile = cfgfile();
savevars.pm view on Meta::CPAN
Just put all the variables to be saved into the @vars array.
=head1 CAVEATS
cfgfile() uses the $< variable to determine the current home
directory. This might not be what you want if using setuid scripts.
=head1 BUGS
Because getpwuid() is used, this module will not work very well on
Windows. Configuration files will be stored in the current drive root
directory or, if the C<$HOME> environment variable exists, in the
C<$HOME> directory.
=head1 AUTHOR
Slaven Rezic <eserte@cs.tu-berlin.de>
Copyright (c) 1998-2001 Slaven Rezic. All rights reserved. This
package is free software; you can redistribute it and/or modify it
( run in 0.317 second using v1.01-cache-2.11-cpan-454fe037f31 )