LPM: filtering
Joe Hourcle
oneiros at dcr.net
Tue Mar 7 13:38:41 CST 2000
On Tue, 7 Mar 2000, Frank Price wrote:
> Hi LexPM,
>
> I want to text-wrap a string to 50 columns before printing it to
> sendmail. In the shell, I'd do this:
>
> echo "Really long string ..." | fmt -50 | mail
>
> How can I do the same in perl? I tried something like the following,
> essentially from the Cookbook, but it just printed to my terminal's
> stdout and then hung until I ctrl-D. I realize I could use a temp
> array to hold the formatted output, but for some reason this seems
> more "elegant" -- is there any way to make it work?
I've never used it, but both the format command, and Text::Wrap chould do
it..
using Text::Wrap, it'd be something like this:
use Text::Wrap;
$Text::Wrap::columns = 50;
my $output = ('', '', $input);
(with $input having the text to wrap, and you using $output for whatever)
Text::Wrap is also covered in Programming Perl
-Joe
More information about the Lexington-pm
mailing list