Skip to content

Instantly share code, notes, and snippets.

@kell05
kell05 / CurrentDate.pl
Created November 23, 2011 11:25
Returns the current date in yyyymmdd format
sub current_date{
my ($d,$m,$y) = (localtime)[3,4,5];
# Normalise dates
($m+=1,$y+=1900);
# Check prefix with zero
$m = "0$m" if ($m < 10);
$d = "0$d" if ($d < 10);
@kell05
kell05 / gist:1242391
Created September 26, 2011 14:45
Trim Strings (Removal of prepending and appending white space)
sub trim($) {
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}