in reply to An odd flat file database question

I'm trying to think of a way in which you would not get the endpoints of a range. Perhaps if you showed some code, we could help more.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re (tilly) 2: An odd flat file database question
by tilly (Archbishop) on Feb 08, 2001 at 07:07 UTC
    If there are 10 records with the final catalog number, I can easily see naive code only printing one of them.
Re: Re: An odd flat file database question
by Stamp_Guy (Monk) on Feb 08, 2001 at 06:46 UTC
    Hey Merlyn, My code accepts two arguements: First and Last. It just goes through the database and when it finds the first, it starts a loop that prints and increments a counter until it reaches the last number. It then prints the footer and exits. Really simple, really bulky, really sloppy, and a pain in the rear end to update. Also, I'm reading in the entire file into an array each time I do this. The file is about 250k. Do you think that it is pushing it to do that? Is there any quicker, perhaps more memory efficient way to do it? I'd give you the code, but I really don't think it will do any good after explaining what I did above. Let me know.

      There are a couple, but they all involve changing the format in which your data is stored. As others in this thread have mentioned, you can use DB_File and its ilk, or (my recommendation) an RDBMS like MySQL or Postgres (both available for the cost of a download, with plenty of online help). Perl's DBI interface is robust and mature, so you shouldn't have too much trouble making the transition. It can't hurt to know some SQL =)

      Philosophy can be made out of anything. Or less -- Jerry A. Fodor