linux - 如何将shell脚本case语句转换为perl脚本

标签 linux perl shell

如何为shell脚本的以下情况stmt编写perl脚本

sciptname=$0
case ${sciptname} in
  /*) scriptlocation=`dirname ${sciptname}`;;
   *) scriptlocation=`dirname ${pwd}/${sciptname}`;;
esac

最佳答案

使用Cwd库函数abs_path

use Cwd 'abs_path';
my $script_location = abs_path( $0 );

关于linux - 如何将shell脚本case语句转换为perl脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40669218/

相关文章:

postgresql - 如何使用 perl 和 postgresql 遍历大型结果集

.net - LAN 唤醒 Powershell 脚本不起作用

php - 如何检索 PHP exec() 错误响应?

bash - 这个错误是什么意思? (SC2129 : Consider using { cmd1; cmd2; } >> file instead of individual redirects.)

linux - 将公钥添加到服务器的authorized_keys 文件后是否应该删除它?

linux - Linux内核中syscalls.h中函数的实现在哪里

linux - 如何将文本添加到同一行?

Perl - 如何跳过先前处理中已读取的行

perl - 如何重新加载 'require' 调用的内容?

php - 如果启用了 libcurl,我可以假设所有 setopt 选项都可用吗?