Config-INI

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

          subclassing more flexible

0.023     2014-03-13 10:21:15+01:00 Europe/Paris
        - specify minimum Mixin::Linewise requirement (thanks, Andreas Koenig
          and Smylers)

0.022     2014-01-30 16:57:43-05:00 America/New_York
        - remove the last few places IO::String was used (thanks, Graham Knop)

0.021     2013-10-20 11:33:59 America/New_York
        - throw an exception if line 1 appears to start with a UTF-8 BOM
        - typo fixes in docs (thanks, David Steinbrunner!)

0.020     2013-07-01 21:30:50 America/New_York
          update bugtracker

0.019     2011-12-15 17:03:14 America/New_York
          provide handle_unparsed_line

0.018     2011-06-02 21:51:50 America/New_York
          bump up version of IO::File required (thanks, ABH!)

examples/utf8-bom.ini  view on Meta::CPAN

stupid = this ; This file should be saved with a BOM even though it's UTF-8!

lib/Config/INI/Reader.pm  view on Meta::CPAN

#pod =cut

sub read_handle {
  my ($invocant, $handle) = @_;

  my $self = ref $invocant ? $invocant : $invocant->new;

  # parse the file
  LINE: while (my $line = $handle->getline) {
    if ($handle->input_line_number == 1 && $line =~ /\A\x{FEFF}/) {
      Carp::confess("input handle appears to start with a BOM");
    }

    $self->preprocess_line(\$line);

    next LINE if $self->can_ignore($line, $handle);

    # Handle section headers
    if (defined (my $name = $self->parse_section_header($line, $handle))) {
      # Create the sub-hash if it doesn't exist.
      # Without this sections without keys will not

t/reader-err.t  view on Meta::CPAN

  my $data  = eval { Config::INI::Reader->read_string($input); };
  like($@, qr/Syntax error at line 1:/i, 'syntax error');
}

{
  my $ok = eval {
    my $hashref = Config::INI::Reader->read_file( 'examples/utf8-bom.ini' );
    1;
  };
  my $error = $@;
  ok( ! $ok, "we can't read a UTF-8 file that starts with a BOM");
  like($error, qr/BOM/, "the error message mentions a BOM");
}

done_testing;



( run in 1.131 second using v1.01-cache-2.11-cpan-e9daa2b36ef )