How would I know?

In your code, here:

{ # reduce bogus warnings no warnings 'uninitialized'; # get past the header ( $token_type, $argument, $parameter ) = $tokenizer->get_token() until ($token_type eq 'control' and $argument eq 'par'); }

you call ->get_token(), which reads a set of tokens and throws them away.

Maybe consider changing your code to:

my @tokens; { # reduce bogus warnings no warnings 'uninitialized'; do { # get past the header ( $token_type, $argument, $parameter ) = $tokenizer->get_token(); push @tokens, [$token_type, $argument, $parameter]; } until ($token_type eq 'control' and $argument eq 'par'); }

and then, when writing your output document, first output all the saved stuff from @tokens.

I don't know RTF and I don't know your input document and I don't know your wanted output stuff, so I can't give much more concrete help.

While you cannot help me with the first issue, you can help me with the second and third issue by posting a short example of your RTF input and wanted RTF output, especially including a part that contains random coloured stuff or whatever you want to keep. If I have this, I guess that would be enough for me to fake knowing RTF enough to keep the formatting.


In reply to Re^3: Keeping RTF formatting when moving files by Corion
in thread Keeping RTF formatting when moving files by mdavies23

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.