Home > Articles > Web Development > Perl

  • Print
  • + Share This
From the author of

Conclusion

Many files, such as log files, can not only begin to clog up directories, but they can also take up too much space. File compression not only helps to aleviate this, but by adding a dash of Perl scripting you can easily view the contents of these files. This example, although useful on its own, can be modified to be used from the command line as well. Also, extra features could be added, such as; the ability to remove and add files to tars, and accessing and viewing other file formats (such as images).

One of the obvious used for this is to gzip up a lot of images which you use on a web site, and display them from within the compressed file. I will leave it as an exercise to the reader to implement that (which should take you only a few minutes). But, I used text files as an example because you can really see a difference in the amount of disk space saved. Text files leave a lot of room for compression, so gzipped files filled with text files are nicely compressed. However, image files are already (somewhat) compressed. When compressing jpeg images, for example, the file may actually be larger than the sum of the individual files! This is because jpegs are pretty compact. However, with gif, png and other formats you may see some disk space saved.

So, take this code, use it, abuse it, learn from it, and keep hacking Perl!

  • + Share This
  • 🔖 Save To Your Account