- 脚本位置信息
1234567891. (子)脚本所在的位置:/home/wangyu/File::Specmy $path_curf = File::Spec->rel2abs(__FILE__);my ($vol, $dirs, $file) = File::Spec->splitpath($path_curf);2. 从哪里调用的(主)脚本:/home/wangyu/code$ENV{'PWD'}3. 程序目前切换(chdir)到哪里了:/lustre/Work`pwd`注意:<code>`pwd` 的返回值需要chomp去除末尾回车;</code> 解释: 1. 我用a.pl调用b.pl,主脚本为a.pl,子脚本为b.pl; 2. a.pl在/home/wangyu/code/perl, b.pl在/home/wangyu; 3. 使用chdir切换了到/lustre/Work以后,调用b.pl,在b.pl里面,使用三种方式判断路径。
11. 在windows系统下git环境中,使用pwd获得的路径格式为‘/a/b/c’,这个路径如果搭配‘chdir’使用,就会提示找不到;此时需要使用Cwd模块中的getcwd()函数 - perl -d: 打开调试功能
- windows下,html中指定路径:”file:\/\/\/path_to_the_file”;
- 对读入的数据进行split前,注意,要用chomp处理;
因为,读入的数据的末尾的换行符会被分配到最后一串字符里。
其实际影响案例有:1. 如果一个变量$var包含了换行符,我把这个变量放在system “gzip -d -c $var > filename”,这条命令$var后面的就无法生效,因为在$var已经敲了回车了。 - Installation:
12perl -MCPAN -e shellinstall SOAP::Lite - Your Perl is configured to link against libgdbm,but libgdbm.so was not found.:aptitude install libgdbm-dev
- Please tell me where I can find your apache src:
- Function Round: int($number+0.5)
- ‘Unquoted string “..” may clash with future reserved word
I meet this warning because my filehandle is lowercase with the “warning” on. It’s better to use uppercase as developers wish. - 重要的变量:
12$$: 该脚本的进程号;$|=1;#即时将输出内容打印到屏幕,不缓冲; - 微型Perl: 修改文件内容
1perl -p -i -e 's/from/to/' *.file-p:输出本行内容(-n: 不输出本行内容)
-i:指定备份文件后缀名,如果给出-i选项并且没有指定后缀名,则覆盖原文件 (-i.bak)
-e:需要运行的perl代码,分号分割,可写多条语句。计数变量可用。
*.file: 需要修改的文件 - 已安装模块备份及重装
123456#所有安装的模块信息存储在:#/home/nott/.cpan/Bundle/Snapshot_2017_03_10_00.pmperl -MCPAN -eautobundle#重装perl -MCPAN -e 'install Bundle::Snapshot_2017_03_10_00' - 选择性正则匹配:/(.snp.gz|.snp.tar.gz|.snp)/,匹配上的模式保存在$1
- strict refs
12Can't use string as a symbol ref while "strict refs" in useCan't use string as a HASH ref while "strict refs" in use - asdf