in reply to Re: Centering Text with GD::Image
in thread Centering Text with GD::Image
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Centering Text with GD::Image
by pryrt (Abbot) on Nov 04, 2021 at 13:21 UTC | |
by kcott (Archbishop) on Nov 05, 2021 at 06:14 UTC | |
by pryrt (Abbot) on Nov 05, 2021 at 13:56 UTC | |
by hippo (Bishop) on Nov 05, 2021 at 14:23 UTC | |
by Bod (Parson) on Nov 06, 2021 at 20:14 UTC | |
by kcott (Archbishop) on Nov 09, 2021 at 04:54 UTC | |
by Bod (Parson) on Nov 16, 2021 at 13:45 UTC | |
by pryrt (Abbot) on Nov 05, 2021 at 19:43 UTC | |
Re^3: Centering Text with GD::Image
by Bod (Parson) on Nov 05, 2021 at 00:29 UTC | |
by kcott (Archbishop) on Nov 05, 2021 at 07:10 UTC |