This is the sidebar. Without it, the main text is too wide!
- Genome project
- Linux
2019년 11월 교육 자료
- 실습용 스크립트 구글 문서라서 접속 환경에 따라 열리지 않을 수도 있습니다.
This is the sidebar. Without it, the main text is too wide!
2019년 11월 교육 자료
#!/usr/bin/perl # https://stackoverflow.com/questions/12400217/replace-a-field-with-values-specified-in-another-file # answer by Vijay; later modified by Haeyoung Jeong use strict; use warnings; if ($#ARGV < 1) { print STDERR "Usage : $0 <key-value-file> <file-to-be-modified>\n"; print STDERR " First file should use tab for the field separator.\n"; exit; } my %hsh=(); open (MYFILE, $ARGV[0]); open (MYFILE2, $ARGV[1]); while (<MYFILE>) { my@arr = split/\s+/; $hsh{$arr[0]} = $arr[1]; } my $flag; while(<MYFILE2>) { $flag=0; my $line=$_; foreach my $key (keys %hsh) { if($line=~/$key/) { $flag=1; $line=~s/$key/$hsh{$key}/g; # print $line; } } print $line; if($flag!=1) { print $line; $flag=0; } } close(MYFILE); close(MYFILE2);