I use osql to run several sql scripts against the database, and then I need to look at the result file to see if there are any errors. The problem is that Perl does not seem to like that the result files are Unicode.
I wrote a small test script to test it, and the output will fail:
$file = shift; open OUTPUT, $file or die "Can't open $file: $!\n"; while (<OUTPUT>) { print $_; if (/Invalid|invalid|Cannot|cannot/) { push(@invalids, $file); print "invalid file - $inputfile - schedule for retry\n"; last; } }
Any ideas? I tried to decode using decode_utf8 , but that doesn't make any difference. I also tried to set the encoding when opening the file.
I think the problem may be that osql puts the result file in UTF-16 format, but I'm not sure. When I open the file in the text pane, it just tells me Unicode.
Edit: Using perl v5.8.8 Edit: Hex dump:
file name: Admin_CI.User.sql.results mime type: 0000-0010: ff fe 31 00-3e 00 20 00-32 00 3e 00-20 00 4d 00 ..1.>... 2.>...M. 0000-0020: 73 00 67 00-20 00 31 00-35 00 30 00-30 00 37 00 sg..1. 5.0.0.7. 0000-0030: 2c 00 20 00-4c 00 65 00-76 00 65 00-6c 00 20 00 ,...Le vel.. 0000-0032: 31 00 1.
file encoding perl unicode
Jaco pretorius
source share