我在Perl中运行以下代码

my $exp_date = `date --date="$(openssl x509 -enddate -noout -in certificate.pem | cut -d= -f 2)"  --iso-8601`; 

我得到了:

日期:无效日期Δ100 100 537 539 847 6210 70720 7...

在命令行中运行的确切命令

date --date="$(openssl x509 -enddate -noout -in certificate.pem | cut -d= -f 2)"  --iso-8601

打印is8601格式的实际日期.

在Perl中运行它时,我做错了什么?

推荐答案

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`;
#                            ~

Linux相关问答推荐

在Bluez/Linux中,周期性与连续蓝牙设备发现的已知缺陷是什么?

x64 NASM 汇编程序在程序开始时显示分段错误

加载ELF64头文件为什么会导致分段错误?

如何在不进行轮询且不吃掉其他人子进程的退出代码的情况下等待一组子进程(并且只有它们)?

如何从 AWK 中的 CSV 列中获取中值? (Linux)

如何使用正则表达式在 LINux 中查找具有不同结尾的多个文件?

用户级线程如何与内核级线程对话

查找更高版本的文件

如何从linux调度程序中屏蔽一个cpu(防止它调度线程到那个cpu上)?

使用 AWS CLI 进行 Bash - 无法找到凭证

-zxvf 在 tar -zxvf <文件名> 中是什么意思?

在 bash 中检测公共 IP 地址的方法

grep 时间命令输出

在 VIM 中搜索和替换导致尾随字符

如何删除 Mercurial 存储库

如何让 GNU 屏幕读取 .bash_profile/.bash_rc 更改?

用于 ssh 的类似 teamviewer 的工具?

如何显示正在运行的进程列表 Python?

Linux 上真的没有异步块 I/O 吗?

.NET Core 中的跨平台文件名处理