http://qs321.pair.com?node_id=464308


in reply to Re: Reopen file when contents changed?
in thread Reopen file when contents changed?

sub first_line_from_file { my $fn = shift; open my $file, "<", $fn or die "unable to open file $fn"; <$file> }
To return the first line I'd say
scalar <$file>;
(The semicolon is cosmetic. But I consider it good style)