package IdPAccountManager::Configuration; use strict; use warnings; use English qw(-no_match_vars); sub new { my ($pkg) = shift; my %args = @_; die "missing argument 'file'" unless $args{file}; die "non-existing file $args{file}" unless -f $args{file}; die "non-readable file $args{file}" unless -r $args{file}; my $self = {}; my $handle; open($handle, '<', $args{file}) or die "Failed to open $args{file}: $ERRNO"; while (my $line = <$handle>) { next unless $line =~ /^(\S+)\s*=\s*(.+)$/; my $key = $1; my $val = $2; $self->{$1} = $2; } close $handle; bless $self, $pkg; return $self; } 1;