| 20 |
rodolico |
1 |
#!/usr/bin/env perl
|
|
|
2 |
use warnings;
|
| 26 |
rodolico |
3 |
use strict;
|
| 2 |
rodolico |
4 |
|
| 37 |
rodolico |
5 |
# Description: Library used by modules. Do NOT enable
|
| 20 |
rodolico |
6 |
|
| 37 |
rodolico |
7 |
our $VERSION = '1.2';
|
|
|
8 |
|
| 2 |
rodolico |
9 |
# set of libraries to be used by these modules
|
|
|
10 |
|
|
|
11 |
|
| 20 |
rodolico |
12 |
# cleanUp - passed a delimiter and a string, does the following (delimiter can be '')
|
|
|
13 |
# chomps the string (removes trailing newlines)
|
|
|
14 |
# removes all text BEFORE the delimiter, the delimiter, and any whitespace
|
|
|
15 |
# thus, the string 'xxI Am x a weird string' with a newline will become
|
|
|
16 |
# 'a weird string' with no newline
|
|
|
17 |
|
| 2 |
rodolico |
18 |
sub cleanUp {
|
|
|
19 |
my ($delimiter, $text) = @_;
|
|
|
20 |
chomp $text;
|
|
|
21 |
return $text unless $delimiter;
|
|
|
22 |
$text =~ m/[^$delimiter]*$delimiter\s*(.*)/;
|
|
|
23 |
return $1;
|
|
|
24 |
}
|
|
|
25 |
|
|
|
26 |
# checks if a command is valid on this system. If so, returns the full path to it
|
|
|
27 |
# else, returns empty string.
|
|
|
28 |
sub validCommandOnSystem {
|
|
|
29 |
my $command = shift;
|
|
|
30 |
$command = `which $command 2> /dev/null`;
|
|
|
31 |
chomp $command;
|
|
|
32 |
return -x $command ? $command : '';
|
|
|
33 |
}
|
|
|
34 |
|
| 20 |
rodolico |
35 |
1;
|