http://www.perlmonks.org?node_id=950758

preahkumpii has asked for the wisdom of the Perl Monks concerning the following question:

I am working with manipulating text files in Perl, not with Web. I need to be able to take a given string of text, and given a font name and size (ideal other options as well), to output the length of the string in pixels (or whatever unit) as it would appear in the font. I have looked the Tk module and on the web extensively. I cannot find a clear description of its use at all. Here is my sample code:
#!/usr/bin/perl use warnings; use strict; use Tk; my $happy = "This is my example sentence"; # I want the measurement of the above string in pixels given a font fa +ce and font size
Thanks for the help. Adam