Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Estimating height of TEXTAREA from content

by simonm (Vicar)
on Jul 25, 2005 at 05:33 UTC ( #477688=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Estimating height of TEXTAREA from content
in thread Estimating height of TEXTAREA from content

Given an 80-character soft-wrapping of a multi-paragraph scalar of English words in a monospace font ($content), what will the height of it be in characters ($rows)?

Wrap it yourself and count the lines:

use Text::Wrap; my $rows = split("\n", fill('','', $content););


Comment on Re^3: Estimating height of TEXTAREA from content
Download Code
Re^4: Estimating height of TEXTAREA from content
by Your Mother (Chancellor) on Jul 25, 2005 at 06:39 UTC

    Nice! In a fit of jealousy for not having thought of this myself I'll point out that the default column width for Text::Wrap is 76 characters. So an amended line if the stated 80 is the real case.

    use Text::Wrap; $Text::Wrap::columns = 80; # and continue as above...
Re^4: Estimating height of TEXTAREA from content
by tomazos (Deacon) on Jul 25, 2005 at 15:58 UTC
    Thanks. FYI: Use of implicit split to @_ deprecated.

    my @rows = split("\n", fill('','', $content)); my $rows = $#rows + 1;

    Maybe?

    -Andrew.


    Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://477688]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2015-07-07 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (85 votes), past polls