java顯示聲響波形圖示例。本站提示廣大學習愛好者:(java顯示聲響波形圖示例)文章只能為提供參考,不一定能成為您想要的結果。以下是java顯示聲響波形圖示例正文
即便翻開了strict和warnings選項也不妨,上面代碼並沒有毛病和正告。
#!/usr/bin/perl
use strict;
use warnings;
sub test {
$a = 1;
$b = 2;
print $a, "\n";
print $b, "\n";
}
test();
1;
上面是perl文檔中對這兩個變量的說明:
perldoc perlvar
$a
$b Special package variables when using sort(), see "sort" in perlfunc.
Because of this specialness $a and $b don't need to be declared (using use vars, or our()) even when using the "strict 'vars'" pragma. Don't lexicalize them with "my $a" or "my $b" if you want to be able to use them in the sort() comparison block or function.
上面把子法式中的 $DNA 停止公有變量聲明:
#!/bin/perl
#上面是一段DNA序列
$DNA=ATTATATAT;
$result=A_to_T($DNA);
print "I changed all $DNA A to T, and the we get the result $result\n\n";
sub A_to_T
{
my ($input)=@_;
my $DNA=$input;
$DNA=~s/A/T/g;
return $DNA;
}
成果以下:
F:\>perl\a.pl
I changed all ATTATATAT A to T, and the we get the result TTTTTTTTT
F:\>
如許就正常了。
固然你可以說,在子法式中可以完整不消$DNA這一個變量,就好像上面一樣:
#!/bin/perl
#上面是一段DNA序列
$DNA=ATTATATAT;
$result=A_to_T($DNA);
print "I changed all $DNA A to T, and the we get the result $result\n\n";
sub A_to_T
{
my ($input)=@_;
$dna_to_change=$input;
$dna_to_change=~s/A/T/g;
return $dan_to_change;
}
獲得的也是正常的成果:
F:\>perl\a.pl
I changed all ATTATATAT A to T, and the we get the result
F:\>
然則,沒有人可以或許包管你不會一時懵懂,在子法式用了法式中的變量。或許當你第一次應用的時刻,可以免,當你過去幾個月今後回過火再來應用的時刻,就不克不及包管完整准確了,所認為了代碼的通用性,照樣在一切的子法式中應用my公有變量吧。