Perl keeps track of online orders

Installation

The script needs the Sysadm::Install, Cache::FileCache, DateTime, and DateTime::Format::Strptime modules from CPAN, which are best installed by way of a CPAN shell to resolve dependencies automatically. Alternatively, you can use your Linux package manager if its repository has all of the required modules on hand. Their names might be slightly different in this case, though: libsysadm-install-perl, for example, is Debian's idea of Sysadm::Install.

Before you start, you will need to set up an empty server-side repository manually with the use of git init (Figure 2). Perl modules are not required on the hosted machine; however, you do need the git program, but it is part of most of today's Linux systems anyway.

Figure 7 shows how the first client initializes its local repository, uses shop buy to enter a couple of purchases, runs shop list to query the local database, and ultimately transfers data to the server with shop push. The shop commands do not produce any output if they run successfully.

The second client then uses shop clone to create a local clone of the server repository, as shown in Figure 8. That client also makes a couple of purchases and tags the iPod Nano transaction with Amazon as complete. It then issues a shop push to push the local changes to the server.

The same procedure applies to all further clients; again, they first clone the server repository, make some changes to the local repository, push the new data to the server, and receive the latest updates from the other clients via a server pull. The feast of orders can go on and on, and thankfully, Git will notice immediately any deliveries that fail to reach their destination because of mail problems or supplier sloppiness.

Infos

  1. Listings for this article: http://www.linux-magazine.com/resources/article_code
  2. Swicegood, Travis. Pragmatic Version Control Using Git. Pragmatic Bookshelf, 2008

Read full article as PDF:

Related content

  • Perl: Portfolio Watch

    We'll show you a Perl script that helps you draw area graphs to keep track of your portfolio's performance.

  • Git 101

    When several people collaborate on source code or documents, things can get messy fast. Git provides a quick cure: The distributed versioning system reliably ensures the integrity and consistency of data with minimal effort.

  • Java Content Repository

    Speed up your web development with Jackrabbit, an open source implementation of the Java Content Repository standard.

  • Raspberry Pi Media Center

    Tired of that big clunky media center unit taking up shelf space in your living room? We'll show you how to put together a tiny multimedia system with the versatile and ever-popular Raspberry Pi.

  • Perl: amtrack

    If you are a bargain hunter, you might enjoy this Perl script that monitors price developments at Amazon and alerts you if Amazon suddenly drops the prices on the products you have been watching.

comments powered by Disqus

Direct Download

Read full article as PDF:

News