我從來沒有做過的Perl編程,但我在看下面的Perl代碼,它讓我感到困惑:瞭解一段Perl代碼
sub read_pds
{
my $bin_s;
my $input_pds_file = $_[0];
open(my $fh, '<', $input_pds_file) or die "cannot open file $input_pds_file";
{
local $/;
$bin_s = <$fh>;
}
close($fh);
return $bin_s;
}
我在看上面的代碼,雖然它不會返回任何值,因爲在那裏沒有定義返回類型。
但在底部它返回一個值。現在我怎麼知道什麼是價值的類型,因爲它沒有顯示任何價值,當我使用科莫多添加手錶。
任何想法?
那麼它將返回整個文件,並返回一個字符串?我不確定這個文件的內容是如何看起來的,因爲它具有擴展名.pds,但不應該是Byte []? – TeaLeave
@Califiedicated你稱之爲'Byte []',perl調用一個字符串。 – hobbs
ohk。我很抱歉誤會。 – TeaLeave