in reply to text file database - Objects?
I think you're on the right track, although you might try passing those arguments into the constructor rather than setting them after object creation. Also, if you assign $_ to an actual variable, you ought to use the var rather than rely on the implicit arguments to chomp and split:
Alternatively you might store the objects in a hash where the unique ID is the key.my @objects; foreach my $line (@file) { chomp($line); my ($creg, $cname, $attribs) = split(',', $line); my $object = Blah->new($creg, $cname, $attribs); push(@objects, $object); }
|
|---|