"alle" E-Mail-Adressen per Anhaken als Empfänger hinzufügen können
[kivitendo-erp.git] / SL / Inifile.pm
index 43689d1..30afc66 100644 (file)
@@ -25,7 +25,8 @@
 # GNU General Public License for more details.
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
 #=====================================================================
 #
 # routines to retrieve / manipulate win ini style files
@@ -45,50 +46,40 @@ sub new {
   my ($type, $file, %options) = @_;
 
   my $id = "";
-  my $skip;
+  my $cur;
 
-  local *FH;
+  my $self = { FILE => $file, ORDER => [] };
 
-  my $self = { "FILE" => $file };
+  open my $fh, "$file" or $::form->error("$file : $!");
 
-  open FH, "$file" or $::form->error("$file : $!");
-
-  while (<FH>) {
+  for (<$fh>) {
     chomp;
 
     if (!$options{verbatim}) {
       # strip comments
-      s/\#.*//;
-
       # remove any trailing whitespace
+      s/\s*#.*$//;
       s/^\s*//;
-      s/\s*$//;
     } else {
-      next if (m/^\s*\#/);
+      next if m/^\s*#/;
     }
 
     next unless $_;
 
-    if (m/^\[/) {
-      s/(\[|\])//g;
-
-      $id = $_;
-
-      $self->{$id} ||= { };
+    if (m/^\[(.*)\]$/) {
+      $id = $1;
+      $cur = $self->{$1} ||= { };
 
-      push @{ $self->{ORDER} }, $_;
-
-      next;
+      push @{ $self->{ORDER} }, $1;
+    } else {
+      # add key=value to $id
+      my ($key, $value) = split m/=/, $_, 2;
 
+      $cur->{$key} = $value;
     }
 
-    # add key=value to $id
-    my ($key, $value) = split m/=/, $_, 2;
-
-    $self->{$id}->{$key} = $value;
-
   }
-  close FH;
+  close $fh;
 
   $main::lxdebug->leave_sub(2);