#! /usr/bin/perl -lw use strict; use Shell qw(ps); my $sh = Shell->new; my @pids = grep ( $_ =~ /t\.pl/, $sh->ps('aux')); print "list of running instances:\n@pids\n" ; for( @pids ) { exit if ( $_ && /t\.pl\s.*\-a/ ) ; } print "no other instance running\n" ;