X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FInifile.pm;h=43689d1c032385a034d9b9751063f6b21a78ec21;hb=6d5743899631690b4a82190a977a075c66eb4a0d;hp=f7fe27b3c60fd7afa3c0bdee0a6f616f97dc663b;hpb=db53dc8ab328b82c7af17896487674ad98f2af6b;p=kivitendo-erp.git diff --git a/SL/Inifile.pm b/SL/Inifile.pm index f7fe27b3c..43689d1c0 100644 --- a/SL/Inifile.pm +++ b/SL/Inifile.pm @@ -37,10 +37,12 @@ package Inifile; use IO::File; +use strict; + sub new { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(2); - my ($type, $file) = @_; + my ($type, $file, %options) = @_; my $id = ""; my $skip; @@ -49,19 +51,21 @@ sub new { my $self = { "FILE" => $file }; - open FH, "$file" or Form->error("$file : $!"); + open FH, "$file" or $::form->error("$file : $!"); while () { - next if m/^(#|;|\s)/; - chomp; - # strip comments - s/(#|;).*//g; + if (!$options{verbatim}) { + # strip comments + s/\#.*//; - # remove any trailing whitespace - s/^\s*//; - s/\s*$//; + # remove any trailing whitespace + s/^\s*//; + s/\s*$//; + } else { + next if (m/^\s*\#/); + } next unless $_; @@ -86,7 +90,7 @@ sub new { } close FH; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); return bless $self, $type; } @@ -97,7 +101,7 @@ sub write { my ($self) = @_; my $file = $self->{FILE}; - my $fh = IO::File->new($file, "w") || Form->error("$file : $!"); + my $fh = IO::File->new($file, "w") || $::form->error("$file : $!"); foreach my $section_name (sort keys %{ $self }) { next if $section_name =~ m/^[A-Z]+$/; @@ -114,4 +118,3 @@ sub write { } 1; -