perl function eof

www.i‮fig‬tidea.com

The eof function in Perl is used to test whether the end of a file has been reached. Here's an example of how to use eof:

open my $fh, '<', 'file.txt' or die "Couldn't open file.txt: $!\n";

while (my $line = <$fh>) {
  print $line;
}

if (eof($fh)) {
  print "Reached end of file\n";
} else {
  print "Did not reach end of file\n";
}

close $fh;

In this example, the open