in reply to Re^3: read a hash from a file
in thread read a hash from a file

opps. Thanks for pointing that out. The code pulls is a few custom libs written by my predecessor that I did't think were needed for this issue. Looks like they were.
sub new { my ($self, %args) = @_; my @required = qw(NAME AGE RANK URL); my %cfg = map {uc $_ => $args{$_}} keys %args; for my $req (qw(NAME AGE RANK URL)) { croak "Required argument $req not found" unless exists $cfg{$req}; } return bless \%cfg, $self; }

Replies are listed 'Best First'.
Re^5: read a hash from a file
by hdb (Monsignor) on Apr 16, 2013 at 07:08 UTC

    I cannot directly use this but what happens if you add the following to my code above:

    my $record = REC->new( %data ); print Dumper( $record );
      It works! You are a genuis! Is there anyway to do it without using the intermediary %data ?

        Try this:

        my $record = REC->new( map{ s/#.*//; s/^\s+//; s/\s+$//; m/(.*?)\s*=\s*(.*)/; } read_file($file) );