I'm working my way through Higher Order Perl, and want to try to execute some of its code, in this case FlatDB.pm
.
I tried to simulate the calling method outlined in the answers to this question (2621225), but it's not working for me. To wit:
## HOP Chapter 4 section 3.4, p.140
my $FIELDSEP = qr/:/;
package FlatDB;
sub new {
my $class = shift;
my $file = shift;
open my $fh, "< $file" or return;
chomp(my $schema = <$fh>);
my @field = split $FIELDSEP, $schema;
my %fieldnum = map { uc $field[$_] => $_ } (0..$#field);
print "\nfieldnum=",%fieldnum;
bless { FH => $fh, FIELDS => \@field, FIELDNUM => \%fieldnum,
FIELDSEP => $FIELDSEP } => $class;
}
# More subs here - snipped
What I added to try to run the package:
package main;
print "\nat 89";
$obj= FlatDB->new("FlatDB","SampleDB.txt");
print "\nat 91";
The prints at 89 & 91 are executed, but the print in the 'new' subroutine is not. The 'new' subroutine works if I pull it out of the package, so the problem must be in how I'm trying to call it.
I'm afraid it's something very simple, but I don't see it.