Redian新闻
>
请高手帮助几道 perl 编程题
avatar
请高手帮助几道 perl 编程题# JobHunting - 待字闺中
i*5
1
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";
}
}
}
多谢!
avatar
g*e
2
家庭作业还是应该自己做

be
input

【在 i****5 的大作中提到】
: 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

avatar
b*m
3
呵呵。不过这几个Perl题总体不难。Perl是我最喜欢的语言之一。

【在 g**e 的大作中提到】
: 家庭作业还是应该自己做
:
: be
: input

avatar
g*e
4
维护个几十万行的perl project看看还喜欢不?写个script处理一下文本还行

【在 b***m 的大作中提到】
: 呵呵。不过这几个Perl题总体不难。Perl是我最喜欢的语言之一。
avatar
b*m
5
哈哈哈哈,俺还真曾经开发加维护过两个,没有统计过代码量,但是都是商业级别的论
坛和综合论坛,估计几十万行没有。

【在 g**e 的大作中提到】
: 维护个几十万行的perl project看看还喜欢不?写个script处理一下文本还行
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。