smford22 has asked for the wisdom of the Perl Monks concerning the following question:
I declare a global array of hashes at the beginning of the script with:@AoH = ( { $certName => $validTo, $certName => $validTo, } );
I have the following subroutine setup to parse through the output from the keytool to pull the certificate names and the date they are valid to:our @foundCertificates();
I know that my regular expressions work as the script captures the three certificates in my keystore, but what I cannot figure out to do is how to push the $certname and the $validTo in the array as a pair. I am not sure what other information I can provide, but any help is greatly appreciated. Thanks, Scottsub parseResponse { my $out = shift; my $certname; my $validTo; my $retMonth; foreach my $line (split ("\n", $out)) { if ($line =~ m/^(Alias\sname:\s)(.+)/) { $certname = $2; #print "$certname\n"; } elsif ($line =~ m/^(Valid\sfrom:\s\w+\s)(\w+)\s(\d\d)\s(\d\d:\ +d\d:\d\d)\s\w+\s(\d+)\s(until:)\s\w+\s(\w+)\s(\d\d)\s(\d\d):(\d\d):(\ +d\d)\s\w+\s(\d\d\d\d)/) { $retMonth = &convertMonth($7); $validTo = timegm($11,$10,$9,$8,$retMonth,$12); #print "$validTo\n"; } } #print "$certname - $validTo\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Looping through text and adding values to hash
by ww (Archbishop) on Jul 10, 2013 at 18:21 UTC |