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

hok_si_la has asked for the wisdom of the Perl Monks concerning the following question:

Good localtime friends,

I recently inherited a project at work that requires storing information about collections of images. Essentially each image that comes through has the following attributes:

1)Name of the collection it belongs to
2)Number of images in collection
3)Image number _ of _ in collection
4)File name of image

As these come in I need to store the information above until the final image of the collection is processed. I was thinking about creating a file (collectionname.dat) using a format like ...

Number of images => 5 1 => image1.jpg 2 => image2.jpg 4 => image4.jpg 5 => image5.jpg

So in the example above I have not received the third image of the collection.Each time I receive an image I have to perform the following:

1)Check for existence of dat file. Create one if required
2)lock the file (concurrency)
3)check to see if the latest image completes the collection
  3a)If not, write the image information to a file
  3b)If it does, send the collection out and delete my dat file

Now on to the question. Any ideas on suggestions to make this quicker and easier? Currently the use of a DB is not an option.

Cheers,
Hok