Config-Std
view release on metacpan or search on metacpan
lib/Config/Std.pm view on Meta::CPAN
$first = 0;
}
$block->ensure_gap();
push @{$array_rep_for{$hash_ref}}, $block;
}
open my $fh, '>', $filename
or croak "Can't open config file '$filename' for writing (\L$!\E)";
flock($fh,LOCK_EX|LOCK_NB)
|| croak "Can't write to locked config file '$filename'"
if ! ref $filename;
my $first = 1;
for my $block ( @{$array_rep_for{$hash_ref}} ) {
print {$fh} $block->serialize($first, scalar caller, $post_gap);
$first = 0;
}
flock($fh,LOCK_UN) if ! ref $filename;
lib/Config/Std.pm view on Meta::CPAN
return 1;
}
sub _load_config_for {
my ($filename, $hash_ref) = @_;
open my $fh, '<', $filename
or croak "Can't open config file '$filename' (\L$!\E)";
flock($fh,LOCK_SH|LOCK_NB)
|| croak "Can't read from locked config file '$filename'"
if !ref $filename;
my $text = do{local $/; <$fh>};
flock($fh,LOCK_UN) if !ref $filename;
my @config_file = Config::Std::Block->new({ name=>q{}, first=>1 });
my $comment = q{};
my %seen;
# Start tracking whether section markers have gaps after them...
$post_section_gap_for{$hash_ref} = 0;
lib/Config/Std.pm view on Meta::CPAN
=head1 DIAGNOSTICS
=over
=item Can't open config file '%s' (%s)
You tried to read in a configuration file, but the file you specified
didn't exist. Perhaps the filepath you specified was wrong. Or maybe
your application didn't have permission to access the file you specified.
=item Can't read from locked config file '$filename'
You tried to read in a configuration file, but the file you specified
was being written by someone else (they had a file lock active on it).
Either try again later, or work out who else is using the file.
=item Scalar second argument to 'read_config' must be empty
You passed a scalar variable as the destination into C<read_config()>
was supposed to load a configuration file, but that variable already had
a defined value, so C<read_config()> couldn't autovivify a new hash for
lib/Config/Std.pm view on Meta::CPAN
was originally loaded using C<read_config()>, or else provide an explicit
filename as the second argument to C<write_config()>.
=item Can't open config file '%s' for writing (%s)
You tried to update or create a configuration file, but the file you
specified could not be opened for writing (for the reason given in the
parentheses). This is often caused by incorrect filepaths or lack of
write permissions on a directory.
=item Can't write to locked config file '%s'
You tried to update or create a configuration file, but the file you
specified was being written at the time by someone else (they had a file
lock active on it). Either try again later, or work out who else is
using the file.
=back
=head1 CONFIGURATION AND ENVIRONMENT
( run in 0.547 second using v1.01-cache-2.11-cpan-49f99fa48dc )