T
timb
Hello.
I am writing a perl program that takes in a config file with different
regular expressions and parameters to parse dates. The date is in the
format of 2006/12/03 and I want it in the format of 12/03/2006 so I can
split it into the $month, $day, and $year
Config file:
TitleRegex = ^(\d{4})\/(\d{2})\/(\d{2})
DateRegex = $2/$3/$1
Config loading method:
open (CONFIG, "configfile.config") ||
die "Couldn't load config file for some reason";
while (<CONFIG>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
no strict 'refs';
$$var = $value;
}
close(CONFIG);
Date parsing subroutine:
sub getdate {
$rsstitle =~ m/$RssTitleRegex/ig;
eval { $DateRegex =~ s/(\$\w+)/$1/eeg };
die if $@;
($month, $day, $year) = split(/\//, $DateRegex);
}
I am writing a perl program that takes in a config file with different
regular expressions and parameters to parse dates. The date is in the
format of 2006/12/03 and I want it in the format of 12/03/2006 so I can
split it into the $month, $day, and $year
Config file:
TitleRegex = ^(\d{4})\/(\d{2})\/(\d{2})
DateRegex = $2/$3/$1
Config loading method:
open (CONFIG, "configfile.config") ||
die "Couldn't load config file for some reason";
while (<CONFIG>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
no strict 'refs';
$$var = $value;
}
close(CONFIG);
Date parsing subroutine:
sub getdate {
$rsstitle =~ m/$RssTitleRegex/ig;
eval { $DateRegex =~ s/(\$\w+)/$1/eeg };
die if $@;
($month, $day, $year) = split(/\//, $DateRegex);
}