sub scanSQLErrorlog { …… # now open the errorlog file for scan: unless (open(LOG, "$sqlErrorlog")) { $ref->{log_open_error} = "***Error: could not open $sqlErrorlog for read. "; $ref->{log_open_error} .= Win32::FormatMessage(Win32::GetLastError); return $ref; } # get the very first errorlog line. It has the version info: $_ = ; if (/^\s*(\d\/\-+\s+\d\:\.+)\s+(?:kernel|Server|spid\d+)\s+(Microsoft\s+SQL\s+Server.+)/i) { ($ref->{first_recorded_date}, $ref->{sql_version}) = ($1, $2); } …… }