summaryrefslogtreecommitdiff
path: root/LedgerSMB/Inifile.pm
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-04-26 18:00:56 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-04-26 18:00:56 +0000
commit666fd833584fe2e3618a397fe9d9a9bdf4c5b94b (patch)
tree19c4444705fd7f7803e0d7b597659c11d7e85b73 /LedgerSMB/Inifile.pm
parent2edd2e4de0f08a0a5f23647ea715f279671a0b89 (diff)
Doing a simple Perltidy commit so that I can evaluate differences between the branches and make sure patches are up to date
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1103 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Inifile.pm')
-rw-r--r--LedgerSMB/Inifile.pm95
1 files changed, 46 insertions, 49 deletions
diff --git a/LedgerSMB/Inifile.pm b/LedgerSMB/Inifile.pm
index 839c19f3..1b89502c 100644
--- a/LedgerSMB/Inifile.pm
+++ b/LedgerSMB/Inifile.pm
@@ -1,8 +1,8 @@
#=====================================================================
-# LedgerSMB
+# LedgerSMB
# Small Medium Business Accounting software
# http://www.ledgersmb.org/
-#
+#
# Copyright (C) 2006
# This work contains copyrighted information from a number of sources all used
# with permission.
@@ -35,60 +35,57 @@
package Inifile;
-
sub new {
- my ($type, $file) = @_;
+ my ( $type, $file ) = @_;
- warn "$type has no copy constructor! creating a new object."
- if ref($type);
- $type = ref($type) || $type;
- my $self = bless {}, $type;
- $self->add_file($file) if defined $file;
+ warn "$type has no copy constructor! creating a new object."
+ if ref($type);
+ $type = ref($type) || $type;
+ my $self = bless {}, $type;
+ $self->add_file($file) if defined $file;
- return $self;
+ return $self;
}
-
sub add_file {
- my ($self, $file) = @_;
-
- my $id = "";
- my %menuorder = ();
-
- for (@{$self->{ORDER}}) { $menuorder{$_} = 1 }
-
- open FH, '<', "$file" or Form->error("$file : $!");
-
- while (<FH>) {
- next if /^(#|;|\s)/;
- last if /^\./;
-
- chop;
-
- # strip comments
- s/\s*(#|;).*//g;
-
- # remove any trailing whitespace
- s/^\s*(.*?)\s*$/$1/;
-
- if (/^\[/) {
- s/(\[|\])//g;
- $id = $_;
- push @{$self->{ORDER}}, $_ if ! $menuorder{$_};
- $menuorder{$_} = 1;
- next;
- }
-
- # add key=value to $id
- my ($key, $value) = split /=/, $_, 2;
-
- $self->{$id}{$key} = $value;
-
- }
- close FH;
-
-}
+ my ( $self, $file ) = @_;
+
+ my $id = "";
+ my %menuorder = ();
+
+ for ( @{ $self->{ORDER} } ) { $menuorder{$_} = 1 }
+
+ open FH, '<', "$file" or Form->error("$file : $!");
+
+ while (<FH>) {
+ next if /^(#|;|\s)/;
+ last if /^\./;
+ chop;
+
+ # strip comments
+ s/\s*(#|;).*//g;
+
+ # remove any trailing whitespace
+ s/^\s*(.*?)\s*$/$1/;
+
+ if (/^\[/) {
+ s/(\[|\])//g;
+ $id = $_;
+ push @{ $self->{ORDER} }, $_ if !$menuorder{$_};
+ $menuorder{$_} = 1;
+ next;
+ }
+
+ # add key=value to $id
+ my ( $key, $value ) = split /=/, $_, 2;
+
+ $self->{$id}{$key} = $value;
+
+ }
+ close FH;
+
+}
1;