http://www.perlmonks.org?node_id=460708


in reply to Hash of References in an Object

not what you asked for but... you may want to make your instantiation of copy books more flexible. perhaps add a method to Product::Datafile that takes in an array of filter codes
sub createCopybooks { my $self = shift; my @filterCodes = @_; my %copyBooks; foreach my $filterCode ( @filterCodes ) { my $copyBook = Cobol::Copybook->new({filehandle = +> \*DATA, filter => $filterCode} ); my $copyBookName = 'cpy' . $filterCode; $copyBooks{$copyBookName} = $copyBook; } $self->{copybooks} = \%copyBooks; }
then you can easily change how many copybooks you want like so:
$productDatafile->createCopybooks('00', '01', '04', '42', '99');
hth!