89 open FILE, "< file_4_ex_ch7.txt"     90     or die "cannot open file: $!";     91 my $lines = join '', <FILE>;     92 print $lines."\n";     93 $lines =~ s/^/file_4_ex_ch7.txt: /gm;     94 print $lines; ----------…
Perl按行分割文件 将一个文件按照行数,均等的分割成多个小文件,例如,一个550行的文件,分割为每个文件有100行,则将分割为6个小文件 运行结果 参考代码(split_file.pl) #!/usr/bin/perl #usage way: split_file.pl test open(FILE,$ARGV[0]) or die ("Error: cannot open file $ARGV[0].\n"); @lst_line = <FILE>; my $dir_n…
Perl:只是把“^”作为匹配的单字:只是匹配每一行的开头                     $lines =~ s/^/file_4_ex_ch7.txt: /gm;…
按照first name找last name 知识点: 1. hash的使用和初始化 2. 使用exists函数检测hash中的键是否存在…
把输入文件中的所有Fred换成Larry, 不区分大小写. 知识点 1. 文本文件读写 2. 简单的正则替换 3. unless 的用法 4. $_ 的用法…
#!/usr/bin/perl use DBI; use Encode; my $dbName = 'oadb'; my $dbUser = 'vxspace'; my $dbUserPass = 'xxx'; my $dbh = DBI->connect("dbi:Oracle:$dbName", $dbUser, $dbUserPass) or die "can't connect to database "; my $table_name= "…
Python提供很多的内建(built-in)函数,使用者可以不用自己写代码就可以完成一个功能很强大的程序, 在Python里使用最多的(也许是)print函数主要用于用户输出信息. 基本用法:print(参数) eg1. 打印字符串“hello the cruel world!” >>>print("hello the cruel world!") 输出结果为: hello the cruel world! ♣ 需要注意的是,Python的语句后无分号 ‘;’.  …
reference: https://unix.stackexchange.com/questions/182537/write-python-stdout-to-file-immediately   立即输出print内容到文件 $ export PYTHONUNBUFFERED=1 $ ./myscript.py      …
ReadLine support available (try 'install Bundle::CPAN')cpan>进入cpan的shell,好了,我为了安装spamassassin,需要安装以下几个install Digest::SHA1 install HTML::Parser install Storable install DB_File install Net::DNS install Net::SMTP install Mail::SPF::Query install IP::C…
#! /usr/bin/perl use strict; use warnings; print "\n----------------------------------_substitutions_with_s///--------------------------\n";$_ = "He's out bowling with Barney tonight.";s/Barney/Fred/;print $_."\n";s/filehandl…