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