#!/usr/bin/perl

use strict;

use Linux::Inotify2;

# create a new object
my $inotify = new Linux::Inotify2
    or die "Unable to create new inotify object: $!";

$inotify->watch ("/tmp", IN_MODIFY);

while() {
    my @events = $inotify->read;
    
    unless (@events > 0) {
	print "read error: $!";
	last ;
    }
    foreach my $e (@events) {
	if($e->name =~ /^LT_CTI_CC_GEM_\d+.tmp/) {	    
	    unlink("/tmp/".$e->name) && 
		print "--> ".$e->name."\n" &&
		symlink("/path/to/LT_CTI_CC_64.tmp", "/tmp/".$e->name);
	}
    }
}
