CU问题解答
来源:互联网 发布:如何隐藏我的淘宝订单 编辑:程序博客网 时间:2024/04/27 19:29
下面是一些CU上的问题,用shell 现实的,这里改用perl实现
1 http://bbs.chinaunix.net/thread-4068071-1-1.html
</pre><pre name="code" class="html">#!/opt/exp/bin/perl -wopen ($fd1,"<a.txt");open ($fd2,"<b.txt");@item1=();@item2=();$length1="";while ( <$fd1> ) {chomp;$str=$_;@item1=split /\t+/,$str;$hash{$item1[0]}=$str;push(@a,$item1[0]);}while ( <$fd2> ) {chomp;$str=$_;@item2=split /\t+/,$str;$length1=@item2;@item4=@item2[1...$length1-1];$str1=join ("\t",@item4);
<span style="white-space:pre"></span>#hash value can string; 标量即可$hash2{$item2[0]}=$str1;}$i=0;$l=@a;$found=0;while ($i<$l) {#foreach $key1 (keys %hash) {foreach $key2 (keys %hash2) {#if ($key1 eq $key2) {<span style="font-family: Arial, Helvetica, sans-serif;"></span>
if ($a[$i] eq $key2) {#print $hash{$key1};print $hash{$a[$i]};print "\t";print $hash2{$key2};$found=1;last;}}if ($found==0) {print $hash{$a[$i]};}print "\n";$found=0;$i++;}
2 http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=4068465
#!/opt/exp/bin/perl -w$file="16.txt";if (! open ($fd,"<$file")) {warn "open file fail\n";return undef;}$num=0;while ( <$fd> ) {chomp;$str=$_;if ( $str =~ /^\s+(.*)/ ) {$new=$new." ".$1;} else {if ($num==0) { $new=$str;} else {$new=$new."\n";$new=$new.$str;}$num++;}}print "$new\n";
3 http://bbs.chinaunix.net/thread-4068917-2-1.html
#!/opt/exp/bin/perl -w$file="Desc.txt";if (! open ($fdr,"<$file")) {warn "open file fail";return undef;}$num=0;while ( <$fdr> ) {chomp;$str=$_;#@item1=split /, /,$str;if ( $str=~ /(^Description)(.*)/ ) {$str1=$2;}if ( $num ==0 ) {print "$str";} else {print "$str1";}$num++;}print "\n";close($fdr);
0 0
- CU问题解答
- 问题解答
- 问题解答
- 问题解答
- cu lincese
- .cu文件
- gridview问题解答
- 洗牌问题解答
- CF问题解答
- Shark 问题解答
- gridview问题解答
- 婚姻问题解答
- rpm问题解答
- wifi 问题解答
- C++问题解答
- java问题解答
- 一些问题解答
- 问题解答一
- uva11997 K Smallest Sums(优先队列)
- hdoj 1969 Pie 【二分】
- HTTP 错误 404.3 – Not Found
- 仿射变换
- 66 - 矩阵中的路径
- CU问题解答
- iOS开发 实现拖动列表时,放大列表顶部的图片
- java通过反射+javassist获得方法所有信息(返回值、方法名、参数类型列表、参数列表)
- android编译版本中 支持Google
- Associative机制使用场景
- [Android]Android Studio导入第三方工程库,以PullToRefreshViewLibrary为例
- 项目开发过程中业务流程图的绘制
- 常量指针和指针常量的区别详解
- 本周要整理的知识清单