随笔分类 - Perl
摘要:There are some short expressions in Perl that allow you to test files, which is handy if you want to check what a file allows before using it, or if it exists at all. We'll look at a few of the common tests in this section.ExistenceTo see if a file exists before using it, we can use:if (-e "
阅读全文
摘要:在perl中执行shell脚本命令一般使用system(),传入一个shell命令给system()。如果执行多条shell命令岂不是要执行多个system()? 那么如何通过system()同时执行多条shell命令呢? 通过 ; 或者 && 来合并多条命令,如下: &&的好处可以将后面的ls和c
阅读全文
摘要:Requirement: 为了扩展系统的可移植性,将Perl Job扩展支持Linux和Unix两种操作系统,由于操作系统不同,那么所调用的命令自然有所差别,那么该如何区分执行哪种命令呢? Resolution: 利用 $^O 变量来区别不同的操作系统,在不同的操作系统中 $^O 会有不同的值,例如
阅读全文