Perl
›
関数
›
here
getc関数を使って1文字づつ読み込むこともできます。
my $c = getc $fh;
サンプル
以下は、1文字読み込みのサンプルです。
use strict;
use warnings;
my $file = shift;
print "1: 1文字ずつ読み込む。\n";
open(my $fh, "<", $file)
or die "Cannot open $file: $!";
while (defined (my $c = getc $fh)) {
print $c;
}
close $fh;
Perl
›
関数
›
here