如何在 Perl 程序中将行换行为 45 个字符? [英] How can I wrap lines to 45 characters in a Perl program?

查看:34
本文介绍了如何在 Perl 程序中将行换行为 45 个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Perl CGI 程序编写此文本:

I have this text I am writing in a Perl CGI program:

$text = $message;
@lines = split(/\n/, $text);
$lCnt .= $#lines+1;
$lineStart = 80;
$lineHeight = 24;

我想在 45 个字符后强制返回.我在这里怎么做?

I want to force a return after 45 characters. How do I do that here?

预先感谢您的帮助.

推荐答案

看核心正文::Wrap 模块:

use Text::Wrap;
my $longstring = "this is a long string that I want to wrap it goes on forever and ever and ever and ever and ever";
$Text::Wrap::columns = 45;
print wrap('', '', $longstring) . "\n";

这篇关于如何在 Perl 程序中将行换行为 45 个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆