Backups Blow - BackupsBlow/Programs.pm
#!/usr/bin/perl -w
# Backups Blow by Brandon Low 
#
# Copyright 2007 Brandon Low 
# Released under the terms of the GPL v2
#
# http://lostlogicx.com/backupsblow/

package BackupsBlow::Programs;

use strict;
use Exporter;
our (@EXPORT_OK, %EXPORT_TAGS, @ISA);
@ISA = qw(Exporter);
@EXPORT_OK = qw(&program &needProgram);
%EXPORT_TAGS = ("all" => [@EXPORT_OK]);

use BackupsBlow::Config qw(:read);

use Log::Log4perl;
my $logger=Log::Log4perl->get_logger();

sub program($) {
    my ($name)=@_;
    my $retval=config("PROGRAM_" . $name);
    unless ($retval) {
        chomp($retval=`which $name 2> /dev/null`);
        return undef if ($retval =~ m/(.*not found.*|^$)/);
    }
    return $retval;
}

sub needProgram($) {
    my $retval = program($_[0]);
    die("$_[0] not found in path") unless ($retval);
    return $retval;
}

1;
"I swear by my life and my love of it that I will never live my life for the sake of another person or ask another to live for the sake of mine." --Ayn Rand, Atlas Shrugged
Google
 
© 2002-2010 Brandon Low 63 hits since September 7, 2008