I am running the following code in perl
my $exp_date = `date --date="$(openssl x509 -enddate -noout -in certificate.pem | cut -d= -f 2)" --iso-8601`;
and I get:
date: invalid date ‘100 100 537 539 847 6210 70720 7….
The exact command run in the command line
date --date="$(openssl x509 -enddate -noout -in certificate.pem | cut -d= -f 2)" --iso-8601
prints the actual date in iso8601.
What am I doing wrong when running it in Perl?
>Solution :
The Perl special variable $( (see the documentation) contains the real group id of the process. Backticks interpolate variables. To prevent interpolation, escape the dollar sign by a backslash:
my $exp_date = `date --date="\$(openssl x509 -enddate -noout -in certificate.pem | cut -d= -f 2)" --iso-8601`;
# ~