On Sun, Jul 26, 2009 at 17:37, Harry Putnam<rea...@newsguy.com> wrote:
> I'm a little lost even what to look for to do this.
>
> With a variable like this:
>
> $var = 'American Express offers individuals online access to its world-class 
> Card, Financial, and Travel services, including financial advice, retirement 
> planning, air and hotel reservations and more'
>
> I never know how many words will be in the content.
>
> What can I do to format the output info something like 70 characters
> per line (not splitting any words) and each line to begin with 4
> spaces.

I believe you want either [Text::Wrap][1] (which has been a part of
the core since Perl 5.2):

#!/usr/bin/perl

use strict;
use warnings;

use Text::Wrap;

my $var = 'American Express offers individuals online access to its
world-class Card, Financial, and Travel services, including financial
advice, retirement planning, air and hotel reservations and more';

my $indent = " " x 4;
$Text::Wrap::columns = 70;
print wrap($indent, $indent, $var), "\n";

[1] : http://perldoc.perl.org/Text/Wrap.html


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to