Perl: Reading from file, read, eof
- read
- eof
examples/files/read_file.pl
#!/usr/bin/perl use strict; use warnings; # reading in 30 characters: open my $in, "<", $0 or die $!; my $expected = 30; my $buf; my $actual = read $in, $buf, $expected; if ($actual < $expected) { print "reached end of file\n"; }
# returns TRUE if we are stand at or after the end of file. eof($in)
--source: Edu Maven