sub get_file_from_log(){ my $log_name=shift; open(my $log_file, "<", $log_name); my $file_name; while (){ last if ($file_name) = /^Generated filename\s*=\s*(.+)$/; } return $file_name; }