You needn't pull the whole file into memory just to search for one line.
in reply to Need to search for a string in a file
The caret character,(^), means start of the line in a regex. Read perlre, these meta-characters is the second subject covered.
You can match save and exit the loop in one statement.
open(my $log_file, "<", $log_name);
last if ($file_name) = /^Generated filename\s*=\s*(.+)$/;
print "Good ",qw(night morning afternoon evening)[(localtime)/6]," fellow monks."