G'day Bod,

I recall this (or very similar) code from various questions you were asking some months ago. In isolation, this could be quite confusing; consider labelling it as an extract and then adding a link back to the original code to provide more context. However, that's the least of my issues with your post.

Of far greater concern, is posting code like:

new GD::Image->stringFT(...)

Please read "perlobj: Invoking Class Methods" in general; and specifically the "Indirect Object Syntax" subsection. Note the emboldened "use of this syntax is discouraged"; and later "We recommend that you avoid this syntax". Reasons are given later in that subsection.

I don't recall your original code in any detail which makes suggesting an absolute fix impossible. Maybe replace both lines with something closer to:

GD::Image::->new()->stringFT(...)

Or perhaps create one generic, reuseable object:

my $generic_gd_img = GD::Image::->new(); $generic_gd_img->stringFT(...)

There's potentially other ways to handle this, such as returning @bounds from a subroutine; however, please avoid the indirect syntax in your own code and don't suggest its use to others.

— Ken


In reply to Re^2: Centering Text with GD::Image by kcott
in thread Centering Text with GD::Image by djlerman

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.