diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2004-04-05 15:43:33 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2004-04-05 15:43:33 +0000 |
commit | 6e7b55cae05f4babb0050a5796221c9079e8e6e4 (patch) | |
tree | a4b5566f7629733c7eba7c967ed5601c491a64be /mwc.pl | |
parent | 1dd08a7b7175c535fa94f3239927dbb89ba811f6 (diff) | |
download | MPC-6e7b55cae05f4babb0050a5796221c9079e8e6e4.tar.gz |
ChangeLogTag: Mon Apr 5 10:43:03 2004 Chad Elliott <elliott_c@ociweb.com>
Diffstat (limited to 'mwc.pl')
-rwxr-xr-x | mwc.pl | 82 |
1 files changed, 82 insertions, 0 deletions
@@ -0,0 +1,82 @@ +eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' + & eval 'exec perl -w -S $0 $argv:q' + if 0; + +# ****************************************************************** +# Author: Chad Elliott +# Date: 6/17/2002 +# $Id$ +# ****************************************************************** + +# ****************************************************************** +# Pragma Section +# ****************************************************************** + +use strict; +use Cwd; +use File::Basename; + +my($basePath) = getExecutePath($0); +unshift(@INC, $basePath . '/modules'); + +require MWC; + +# ************************************************************ +# Subroutine Section +# ************************************************************ + +sub which { + my($prog) = shift; + my($exec) = $prog; + my($part) = ''; + my($envSep) = ($^O eq 'MSWin32' ? ';' : ':'); + + if (defined $ENV{'PATH'}) { + foreach $part (split(/$envSep/, $ENV{'PATH'})) { + $part .= "/$prog"; + if ( -x $part ) { + $exec = $part; + last; + } + } + } + + return $exec; +} + + +sub getExecutePath { + my($prog) = shift; + my($loc) = ''; + + if ($prog ne basename($prog)) { + if ($prog =~ /^[\/\\]/ || + $prog =~ /^[A-Za-z]:[\/\\]?/) { + $loc = dirname($prog); + } + else { + $loc = getcwd() . '/' . dirname($prog); + } + } + else { + $loc = dirname(which($prog)); + } + + if ($loc eq '.') { + $loc = getcwd(); + } + + if ($loc ne '') { + $loc .= '/'; + } + + return $loc; +} + + +# ************************************************************ +# Main Section +# ************************************************************ + +my($driver) = new MWC(); +exit($driver->execute($basePath, basename($0), \@ARGV)); |