Index: t/00load.t =================================================================== --- t/00load.t (revision 339) +++ t/00load.t (revision 340) @@ -128,8 +128,11 @@ # Test 13 # Make sure that no warnings are thrown for an empty file $@ = ''; +my $warntext = ''; +$SIG{'__WARN__'} = sub { $warntext = $_[0]; }; eval { $ini = new Config::IniFiles -file => 'blank.ini' }; -ok(!$@ && !defined($ini)); +ok(!$@ && !$warntext && !defined($ini)); +$SIG{'__WARN__'} = 'DEFAULT'; # Test 14 # A malformed file should throw an error message Index: IniFiles.pm =================================================================== --- IniFiles.pm (revision 339) +++ IniFiles.pm (revision 340) @@ -611,7 +611,7 @@ # If there's a UTF BOM (Byte-Order-Mark) in the first character of the first line # then remove it before processing (http://www.unicode.org/unicode/faq/utf_bom.html#22) - ($lines[0] =~ s/^//); + ($lines[0] =~ s/^//) if @lines; # Disabled the utf8 one for now (JW) because it doesn't work on all perl distros # e.g. 5.6.1 works with or w/o 'use utf8' 5.6.0 fails w/o it. 5.005_03 # says "invalid hex value", etc. If anyone has a clue how to make this work @@ -635,7 +635,11 @@ } # Store what our line ending char was for output - ($self->{line_ends}) = $lines[0] =~ /([\015\012\025\n]+)/; + if (@lines) { + ($self->{line_ends}) = $lines[0] =~ /([\015\012\025\n]+)/; + } else { + $self->{line_ends} = $\ || "\n"; + } while ( @lines ) { $_ = shift @lines;