Subversion Repositories camp_sysinfo_client_3

Rev

Rev 7 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 20
Line 1... Line 1...
1
#! /usr/bin/perl -w
1
#!/usr/bin/env perl
-
 
2
use warnings;
-
 
3
 
-
 
4
$main::VERSION = '1.0';
2
 
5
 
3
# set of libraries to be used by these modules
6
# set of libraries to be used by these modules
4
 
7
 
5
 
8
 
-
 
9
# cleanUp - passed a delimiter and a string, does the following (delimiter can be '')
6
# clean up the output of a command. Removes delimiter from text
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
 
7
sub cleanUp {
15
sub cleanUp {
8
   my ($delimiter, $text) = @_;
16
   my ($delimiter, $text) = @_;
9
   chomp $text;
17
   chomp $text;
10
   return $text unless $delimiter;
18
   return $text unless $delimiter;
11
   $text =~ m/[^$delimiter]*$delimiter\s*(.*)/;
19
   $text =~ m/[^$delimiter]*$delimiter\s*(.*)/;
Line 19... Line 27...
19
   $command = `which $command 2> /dev/null`;
27
   $command = `which $command 2> /dev/null`;
20
   chomp $command;
28
   chomp $command;
21
   return -x $command ? $command : '';
29
   return -x $command ? $command : '';
22
}
30
}
23
 
31
 
24
1;
-
 
25
 
32
1;
-
 
33