Your first issue is that $self->{charset} is undefined as this is the only concatenation happening. The real issue is why it is undefined? The splice warning indicates that $self->{DOCUMENT} is either undef or a zero element array.

The problem is the name of the import() sub itself. When you use a module Perl will call that modules import() function if it exists or Exporter's import() function if Exporter is in use (Exporter is uselessly used in this module BTW)

In the new function() we can see:

$self->initialize(); $self->import(@_);

This is fine as initialize() will define {charset} and {DOCUMENT}, before the call to import(). The issue is that import() is called immediately you use RTF::Document, so it gets called before you call new. You can fix the problem with a simple s/import/important_not_to_call_stuff_import/g or similar.

As an asside this module has not been touched since 2000 so is probably abandonware. If you have an interest it might be worth taking over maintenance. There are also modules like RTF::Writer that seem better maintained. If you do take over maintenance then please delete these redundant lines at the top of the module:

require Exporter; .... @ISA = qw(Exporter); @EXPORT = qw(); @EXPORT_OK = qw();

cheers

tachyon


In reply to Re: Unitialized value and splice offset in RTF::Document by tachyon
in thread Unitialized value and splice offset in RTF::Document by inblosam

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.