Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: text file database - Objects?

by djantzen (Priest)
on May 09, 2003 at 03:11 UTC ( [id://256753]=note: print w/replies, xml ) Need Help??


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:

my @objects; foreach my $line (@file) { chomp($line); my ($creg, $cname, $attribs) = split(',', $line); my $object = Blah->new($creg, $cname, $attribs); push(@objects, $object); }
Alternatively you might store the objects in a hash where the unique ID is the key.
"The dead do not recognize context" -- Kai, Lexx

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://256753]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found