in reply to Re: Read INI file
in thread Read INI file

Looking at the grammar in the documentation, it doesn't seem to support values without the assignment operator.

ini-file = { <section> | <empty-line> } empty-line = [ <space> ] <line-ending> section = <section-header> { <value-assignment> | <empty-line> +} section-header = [ <space> ] "[" <section-name> "]" [ <space> ] <line- +ending> section-name = string value-assignment = [ <space> ] <property-name> [ <space> ] "=" [ <space> ] <value> [ <space> ] <line-ending> property-name = string-without-equals value = string

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^3: Read INI file
by Anonymous Monk on Apr 05, 2016 at 08:16 UTC
    Simple solution, subclass and "handle" it instead of throwing error
      #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; my $raw = q{ [section_name] okkey=okvalue RANDOM.txt }; dd( MyReader->read_string( $raw ) ); dd( Config::INI::Reader->read_string( $raw ) ); BEGIN { package MyReader; use parent qw/ Config::INI::Reader /; $INC{'MyReader.pm'}=__FILE__; sub parse_boolean { my( $self, $line ) = @_; return $1 if $line =~ /^(\S+\.\w+)$/m; return; } sub handle_unparsed_line { my ($self, $handle, $line) = @_; if( my( $boolean ) = $self->parse_boolean( $line ) ){ ## die if already have boolean, or whateverlogicyouwant return $self->set_value('boolean', $boolean ); } $self->SUPER::handle_unparsed_line($handle,$line); } 1; } __END__ { section_name => { boolean => "RANDOM.txt", okkey => "okvalue" } } Syntax error at line 4: 'RANDOM.txt ' at - line 11.