Subversion Repositories camp_sysinfo_client_3

Rev

Details | Last modification | View Log | RSS feed

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