Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: Display shortened paragraph

by jbrugger (Parson)
on Feb 01, 2006 at 06:14 UTC ( #526976=note: print w/ replies, xml ) Need Help??

in reply to Re^2: Display shortened paragraph
in thread Display shortened paragraph

By using duff's solution with the Matching the word boundary \b so that you don't chop off the text in the middle of a word.

A clumsy other way to do this :)

use strict; use warnings; my $txt = "just wondering how i can have perl display part of my long +memo. basically i want the first lets say 255 charachters of the para +graph. im really new to perl so i don't know how i would come about t +his? a regex perhaps? just started reading about that today. so basic +ally something like"; my @a = split("",$txt); my $l = 7; for (my $i=0; $i < $l; $i++) { print $a[$i]; $l++ if ($i ==($l-1) && ($a[$i] ne " " )) ; }


Comment on Re^3: Display shortened paragraph
Download Code
Re^4: Display shortened paragraph
by Anonymous Monk on Feb 01, 2006 at 06:19 UTC
    i meant by code given by duff, not graff :)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-29 08:41 GMT
Find Nodes?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?

    Results (185 votes), past polls