Ahh... the first two bytes (ÿþ = 0xFF 0xFE) most likely is a BOM (Byte Order Mark), indicating that the file is UTF-16le or UCS-2le (le=little-endian) encoded (the distinction between UTF-16 and UCS-2 is probably irrelevant in your case — what's essential is that (at least) two bytes are being used to encode a single character).
In order to properly read such files, you need to open them like this:
unless (open LOG, "<:encoding(ucs-2)", $sqlErrorlog) { ...
or
unless (open LOG, "<:encoding(utf-16)", $sqlErrorlog) { ...
(you need Perl 5.8.x for this to work)
When debug-printing your $_, you should then see the line content as expected.
Just in case you're still having problems (in particular with line endings), you might want to see this post of mine, which describes the problem, and a workaround. Good luck.
In reply to Re^3: How to open SQL 2005 errorlog?
by almut
in thread How to open SQL 2005 errorlog?
by jc7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |