早教吧 育儿知识 作业答案 考试题库 百科 知识分享

perl一对多变为一对一原始文件:有两列,以Tab隔开,当然有很多行,我们举其中几行为例:——————————————————————strophanthidinCREBBP,HIF1A,CREB1,EP300,CEBPA,CEBPB,SP1,digoxinCREB

题目详情
perl 一对多变为一对一
原始文件:有两列,以Tab隔开,当然有很多行,我们举其中几行为例:
——————————————————————
strophanthidin CREBBP,HIF1A,CREB1,EP300,CEBPA,CEBPB,SP1,
digoxin CREBBP,CREB1,RPS6KA5,EP300,CEBPA,RPS6KA1,SP1,
hydrastinine NCOA2,CREB1,
puromycin CREBBP,HIF1A,CREB1,CEBPA,CEBPB,
procaine MYOD1,
proscillaridin CREBBP,NCOA2,CREB1,RPS6KA5,EP300,CEBPA,
helveticoside CARM1,CREB1,RPS6KA5,EP300,CEBPA,CEBPB,SP1,
staurosporine CREBBP,CREB1,EP300,CEBPB,
lanatoside_c CREBBP,NCOA2,CREB1,RPS6KA5,EP300,CEBPA,SP1,
digoxigenin CREBBP,NCOA2,CREB1,RPS6KA5,EP300,CEBPA,
……
——————————————————————————
目标:改成一一对应的关系:
——————————————————
strophanthidin CREBBP
strophanthidin HIF1A
strophanthidin CREB1
strophanthidin EP300
strophanthidin CEBPA
strophanthidin CEBPB
strophanthidin SP1
digoxin CREBBP
digoxin CREB1
digoxin RPS6KA5
digoxin EP300
digoxin CEBPA
digoxin RPS6KA1
digoxin SP1
hydrastinine NCOA2
.
————————————————
求,用perl程序怎样简单的实现它?
▼优质解答
答案和解析
#!/usr/bin/perl -wuse strict;die "perl $0 \n" unless(@ARGV == 1);open IN,$ARGV[0];while(){ chomp; my @tmp=split /[ \t,]+/,$_; for(my $i = 1;$i
看了perl一对多变为一对一原始文...的网友还看了以下: