in reply to Re^5: How to open SQL 2005 errorlog?
in thread How to open SQL 2005 errorlog?

I did some tests. It is hard to detect whether the log is a 2005 or pre-2005 by its pathname in our case. The best way would be to get the file's BOM before scanning. Do you know how to apply the module File::BOM, so I can use it? Please advise if you do. Thanks and have a great weekend!

Replies are listed 'Best First'.
Re^7: How to open SQL 2005 errorlog?
by almut (Canon) on Jun 08, 2007 at 22:40 UTC

    Essentially, it's as easy as replacing the open(...) with open_bom(LOG, $sqlErrorlog), the only 'challenge' being that you need to modify your error handling slightly (as open_bom() will croak in case of an error). But something like this should do the trick:

    use File::BOM 'open_bom'; # ... eval { open_bom(LOG, $sqlErrorlog) }; if ($@) { $ref->{log_open_error} = "***Error: $@"; # don't know what Win32::GetLastError would do here # just try it, if you really need it... # $ref->{log_open_error} .= Win32::FormatMessage(Win32::GetLastErr +or); return $ref; }

    File::BOM depends on Readonly, so you want to install that module too (unless you already have it). As both modules are pure Perl, there shouldn't be any problems getting them installed.

    Cheers,
    Almut

      Cheers! It works! Thanks you very very much!!!