60 likes | 264 Views
while(<FILE>){ if($_ =~ /^A/){ print $_; } if($_ =~ /t..e/){ print $_; } if($_ =~ /[st].....[a-z][a-z]/){ print $_; } if($_ =~ /[acgt]/){ print $_; } }. #!/usr/bin/perl $seq = “aaaatttt”; $seq =~ s/a/T/g; print “$seq<br>”; $seq =~ s/t/A/g; print “$seq<br>”;. 配列変数.
E N D
while(<FILE>){ if($_ =~ /^A/){ print $_; } if($_ =~ /t..e/){ print $_; } if($_ =~ /[st].....[a-z][a-z]/){ print $_; } if($_ =~ /[acgt]/){ print $_; } }
#!/usr/bin/perl $seq = “aaaatttt”; $seq =~ s/a/T/g; print “$seq\n”; $seq =~ s/t/A/g; print “$seq\n”;
配列変数 $name1 = “Thomas”; $name2 = “John”; $name3 = “Angela”; $name4 = “Joanna”; @name = ( “Thomas”, “John”, “Angela”, “Joanna”); print $name[1]; for($i = 0;$i <= 3;$i ++){ print “$name[$i] “; } foreach $person (@name){ print “$person “; }
ハッシュ キー → 値 $english{ “Ringo” } = “Apple”; $english{ “Budo” } = “Grape”; $english{ “Ichigo” } = “Strawberry”; print $english{ “Budo” }; $ハッシュ名{ “キー” } = 値; %english = (“Ringo” => “Apple”, “Budo” => “Grape”, “Ichigo” => “Strawberry”);
関数 sub print_author { print “*****************************************\n”; print “ This work was done by Yukichi Fukuzawa\n”; print “*****************************************\n”; print “ Last update: 2003/10/5\n”; } &print_author; &print_author; 関数の定義 sub 関数名{ 処理 } &関数名
関数 sub print_author { my $author_name = $_[0]; print “*****************************************\n”; print “ This work was done by “, $author_name, “\n”; print “*****************************************\n”; print “ Last update: 2003/10/5\n”; } &print_author(“Yukichi Fukuzawa”); # 関数中で$_[0]に入る &print_author(“Shigenobu Okuma”); # 関数中で$_[0]に入る 関数の定義 sub 関数名{ 処理 } &関数名