由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
CS版 - 请高手帮助几道 perl 编程题 (转载)
相关主题
perl 请教求推荐Perl script的快速入门资料,谢谢!
继续请教perl的问题,请帮忙差错!多谢啦!How to efficiently enumerate triangles in a large network?
[合集] 现在学啥scripting language比较好?请教一个好的算法
请问PERL里怎么判断一个list里面包含一个元素怎么把C源代码编译和反编译几道? (转载)
如何用 Shell or Perl script 改 directory name几道算法题求教
紧急求助:怎么批处理修改几百个文件的文件名?求助几道数值运算的数据类型的问题..谢谢!
Linux下如何限制一个命令只能在登陆为指定用户下才能运行? (转载)小窍门: Enable 4GB+ of memory on Vista-32bit
怎样用Perl处理中文文本[转载] EECS should be merged
相关话题的讨论汇总
话题: h3话题: h4话题: foreach话题: print话题: my
进入CS版参与讨论
1 (共1页)
i****5
发帖数: 6
1
【 以下文字转载自 JobHunting 讨论区 】
发信人: imm485 (miumiu), 信区: JobHunting
标 题: 请高手帮助几道 perl 编程题
发信站: BBS 未名空间站 (Thu Nov 22 08:36:55 2012, 美东)
1)write a perl script to merge data files with identical format based on
first field. it takes location of two or more input data files as command
line argument, merges and prints merged data to stdout.the result has to be
sorted on first field. You can assume that all data are sorted in all input
files. You are not allowed to use UNIX “sort” command. Each input tick
data file could have several hundred gigabytes. You should optimize your
solution for memory and CPU usage.
datafile1.txt
2009.12.11,ROD,12.26,90.48
2010.11.10,RKP,220.10,29.03
datafile2.txt
2009.11.11,ROD,12.26,90.48
2009.12.18,RKP,220.10,29.03
2)Writing a PERL script to find the certain pattern /zoo/ in the file and
remove the previous 2 lines including the pattern line;
The test file:
bad 1
zoo
good 1
good 2
good 3
bad 2
bad 3
zoo
good 4
good 5
good 6
bad 4
bad 5
zoo
good 7
bad 6
bad 7
zoo
good 8
3)Run the perl script below. As you will see, by changing the value in %h3,
the script also changes the value for %h4, please provide a brief
explanation. Please also provide a generalized solution for this issue.
my %h1 = ( k1 => "v1" );
my %h2 = ( k2 => \%h1 );
my %h3 = ( k3 => \%h2 );
my %h4 = %h3;
print "h3\n";
foreach my $i ( keys %h3 ) {
print "$i => $h3{$i}\n";
foreach my $j (keys %{$h3{$i}}) {
print " $j => $h3{$i}{$j}\n";
foreach my $k ( keys %{$h3{$i}{$j}}) {
print " $k => $h3{$i}{$j}{$k}\n";
}
}
}
$h3{k3}{k2}{k1} = "v2";
print "h4\n";
foreach my $i ( keys %h4 ) {
print "$i => $h4{$i}\n";
foreach my $j (keys %{$h4{$i}}) {
print " $j => $h4{$i}{$j}\n";
foreach my $k ( keys %{$h4{$i}{$j}}) {
print " $k => $h4{$i}{$j}{$k}\n";
}
}
}
多谢!
1 (共1页)
进入CS版参与讨论
相关主题
[转载] EECS should be merged如何用 Shell or Perl script 改 directory name
哪位搞semantic web的大侠给指条明路?紧急求助:怎么批处理修改几百个文件的文件名?
[转载] 请教个perl 的问题Linux下如何限制一个命令只能在登陆为指定用户下才能运行? (转载)
Fresh CS Ph.D.找工作问题怎样用Perl处理中文文本
perl 请教求推荐Perl script的快速入门资料,谢谢!
继续请教perl的问题,请帮忙差错!多谢啦!How to efficiently enumerate triangles in a large network?
[合集] 现在学啥scripting language比较好?请教一个好的算法
请问PERL里怎么判断一个list里面包含一个元素怎么把C源代码编译和反编译几道? (转载)
相关话题的讨论汇总
话题: h3话题: h4话题: foreach话题: print话题: my