M
mikeharrison56
Hello group, I'm converting a very non-structured binary log file (lots
of variable length records, imbedded in arrays, etc.) and I have a
pattern matching question. To do the conversion I run a set of
substitutions on the data. One substitution I would like to do is to
add a start indicator and then an end indicator around a variable
length array of again variable length records. I.e. add a start
indicator and gobble up a variable number of bytes and then add an end
indicator. I successfully add start indicators of the form:
<record_N length=nnnnn>
Where nnnnn is the number of bytes in the record to follow. I want to
enclose the record with an end indicator of the form </record_N>. I've
tried various forms of matches looking like:
my $record_N_start = '<record_N length=';
my $record_N_end = '</record_N>';
s/($record_N_start)(\d+)(.{\2+4})/$1$2$3$record_N_end/sg;
Any suggestions on why this does not work, or alternate substitutions?
of variable length records, imbedded in arrays, etc.) and I have a
pattern matching question. To do the conversion I run a set of
substitutions on the data. One substitution I would like to do is to
add a start indicator and then an end indicator around a variable
length array of again variable length records. I.e. add a start
indicator and gobble up a variable number of bytes and then add an end
indicator. I successfully add start indicators of the form:
<record_N length=nnnnn>
Where nnnnn is the number of bytes in the record to follow. I want to
enclose the record with an end indicator of the form </record_N>. I've
tried various forms of matches looking like:
my $record_N_start = '<record_N length=';
my $record_N_end = '</record_N>';
s/($record_N_start)(\d+)(.{\2+4})/$1$2$3$record_N_end/sg;
Any suggestions on why this does not work, or alternate substitutions?