D
Dave Roberts
I wrote a program to sort my MySQL log files. It works fine, but I
get about a hundred errors such as:
Malformed UTF-8 character (unexpected continuation byte 0x88, with no
preceding start byte) in pattern match (m//) at ./subtest3.pl line 27,
<DB_Dump> line 1685.
I get an identical error for each of the two lines where I am doing
the regex matching. The part that puzzles me is that after converting
the files to hex, neither the source nor the destination files contain
any of the characters mentioned in the numerous errors.
Here's the code...
#! /usr/bin/perl -w
use strict;
my (@DB_List, @DB_Dump, $line, $DB, $DB_Start, $DB_End,
$Save_To_File);
unless (open(DB_Dump, "/test/log")) {
print ("File Problem");
}
unless (open(outfile, ">>/test/Sorted_DB_Dump")) {
print ("File Problem");
}
@DB_Dump=<DB_Dump>; #put file into a list
my @DB_List=("use sonia_db;","use maris_db;","use psa;"); # names of
three databases
foreach $DB (@DB_List){
print outfile ("$DB\n"); # Stores "use DB" command to file
foreach $line (@DB_Dump){
if ($line =~ m/^($DB)/){ # Check if current DB name is found
$DB_Start=1;
$Save_To_File=1; # save data to file
}
else {
$DB_Start=0;
}
if ($line =~ m/^use/){ # Check if new (unwanted) DB name is
found
$DB_End=1;
}
else{
$DB_End=0;
}
if ($DB_End==1 && $DB_Start==0){ # if the "use" is found and I
know it isn't the current DB
$Save_To_File=0; # stop writing data to file
}
if ($Save_To_File && !$DB_Start && !$DB_End){
print outfile ($line);
}
}
}
______________End of Program
Any ideas?
Thanks, Dave
get about a hundred errors such as:
Malformed UTF-8 character (unexpected continuation byte 0x88, with no
preceding start byte) in pattern match (m//) at ./subtest3.pl line 27,
<DB_Dump> line 1685.
I get an identical error for each of the two lines where I am doing
the regex matching. The part that puzzles me is that after converting
the files to hex, neither the source nor the destination files contain
any of the characters mentioned in the numerous errors.
Here's the code...
#! /usr/bin/perl -w
use strict;
my (@DB_List, @DB_Dump, $line, $DB, $DB_Start, $DB_End,
$Save_To_File);
unless (open(DB_Dump, "/test/log")) {
print ("File Problem");
}
unless (open(outfile, ">>/test/Sorted_DB_Dump")) {
print ("File Problem");
}
@DB_Dump=<DB_Dump>; #put file into a list
my @DB_List=("use sonia_db;","use maris_db;","use psa;"); # names of
three databases
foreach $DB (@DB_List){
print outfile ("$DB\n"); # Stores "use DB" command to file
foreach $line (@DB_Dump){
if ($line =~ m/^($DB)/){ # Check if current DB name is found
$DB_Start=1;
$Save_To_File=1; # save data to file
}
else {
$DB_Start=0;
}
if ($line =~ m/^use/){ # Check if new (unwanted) DB name is
found
$DB_End=1;
}
else{
$DB_End=0;
}
if ($DB_End==1 && $DB_Start==0){ # if the "use" is found and I
know it isn't the current DB
$Save_To_File=0; # stop writing data to file
}
if ($Save_To_File && !$DB_Start && !$DB_End){
print outfile ($line);
}
}
}
______________End of Program
Any ideas?
Thanks, Dave