i have written a parser which searchs in a file for regexps. it all went fine but then i found out, that some of the data files are encoded in unicode.
i tried several things from manuals and books but it just doesn't work. it seems that perl does not use the right encoding, it finds almost no regularexpression and the output is still with the NULs after every character. if i write the same lines in ASCII-File the keywords are found without any problem.
i am using windows xp with active state perl 5.8. thanks vor your help.
#test.pl - testfile with the heart of the parser
#open the file to search trough
unless (open FILE, "<../perl/testproto/Protokoll.log") {
die "Cannot open Keywordfile: $!\n";
}
#search for the regexp in the file
while (<FILE>) {
chomp;
if (/.*Cl(.*)/) {
print $1;
}
else {
print "Keine Treffer.\n";
}
}
Part of the data-file:
keywords to be found: Clinic, Surgon, Patient Code, ...
S: 07:02:36 ----------------------------------------------------------
+----------
S: 07:02:36 Clinic: Knie Klinik
S: 07:02:36 Surgon: Prof X
S: 07:02:36 Patient Code: Kiro
S: 07:02:36 Size: 30 cm
S: 07:02:36 Weight: 50 kg
S: 07:02:36 Birthdate: Sa 1. Jan 2000
S: 07:02:36 Sex: male
S: 07:02:36 Indication:
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|