Config-Std

 view release on metacpan or  search on metacpan

lib/Config/Std.pm  view on Meta::CPAN

341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
        $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

394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
    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

908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
=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

945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
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.353 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )