forked from s1th/system_i_audit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMiscFunc.pm
101 lines (86 loc) · 1.93 KB
/
MiscFunc.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package MiscFunc;
require Exporter;
use strict;
use warnings;
use Cwd;
use Date::Calc qw(:all);
use Text::Levenshtein qw(fastdistance);
our (@ISA, @EXPORT);
@ISA = qw(Exporter);
@EXPORT= qw();
#=================
# Global Variables
#=================
#================
# Local Variables
#================
#================
# Get a timestamp
#================
sub get_timestamp
{
my($sec,$min,$hr,$day,$mon,$yr,$wkday,$dayofyr,$isdst) = localtime(time);
$mon += 1;
$yr += 1900;
my $ts = "$mon" . "." . "$day" . "." . "$yr" . "." . "$hr" . "." . "$min" . "." . "$sec";
return $ts;
}
#==============================
# Get current working directory
#==============================
sub get_cwd
{
my $cwdd = getcwd();
$cwdd =~ s/\//\\/g; #fix up for windows horseshit
#fix trailing slash issue
if ( substr($cwdd,-1,1) eq "\\")
{
substr($cwdd,-1,1) = '';
}
return $cwdd;
}
#================
# Get 90 days ago
#================
sub days_ago_90
{
my($sec,$min,$hr,$day,$mon,$yr,$wkday,$dayofyr,$isdst) = localtime(time);
$mon += 1;
$yr += 1900;
my($nago_yr,$nago_mon,$nago_day) = Add_Delta_Days($yr,$mon,$day,-90);
my $new_nago_yr = substr($nago_yr,2,2);
my $ninety_days_ago = Date_to_Days($new_nago_yr,$nago_mon,$nago_day);
return $ninety_days_ago;
}
#==============================================================
# Trim leading and trailing whitespace characters from a string
#==============================================================
sub trim
{
my($str) = @_;
$str =~ s/^\s+//;
$str =~ s/\s+$//;
return $str;
}
#===================================
# Trim leading whitespace characters
#===================================
sub ltrim
{
my($str) = @_;
$str =~ s/^\s+//;
return $str;
}
#====================================
# Trim trailing whitespace characters
#====================================
sub rtrim
{
my($str) = @_;
$str =~ s/\s+$//;
return $str;
}
#=============
# Return value
#=============
return 1;