構文 |
|
getc ファイル・ハンドル |
返り値 |
|
読み込んだ値 |
説明
- ファイル・ハンドルから1バイト読み込んで返します。ファイルの終わりに達している場合は未定義値を返します。
- ファイル・ハンドルを省略すると標準入力から読み込みます。
使用例
#!/usr/bin/perl
use strict;
use warnings;
my $filename = 'data.dat';
open my $fh, "<", $filename or die "$!:$filename";
binmode $fh;
while (not eof $fh) {
my $ch = getc $fh;
printf "%02X", ord $ch;
}
close $fh;
#!/usr/bin/perl
use strict;
use warnings;
binmode STDIN;
while (not eof STDIN) {
my $ch = getc;
printf "%02X", ord $ch;
}