# perldoc > Text::Wrap

---
type: CommandReference
command: Text::Wrap
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference

- `use Text::Wrap; print wrap($initial_tab, $subsequent_tab, @text);` — Wrap a single paragraph
- `use Text::Wrap qw(wrap $columns $huge); $columns = 132;` — Wrap at 132 columns
- `$Text::Wrap::columns = 72; print wrap('', '', @text);` — Set column width globally
- `use Text::Wrap; @paragraphs = fill($initial_tab, $subsequent_tab, @text);` — Fill multiple paragraphs
- `$huge = 'die';` — Die on words longer than columns

## Name

**Text::Wrap** — line wrapping to form simple paragraphs

## Synopsis

perl
use Text::Wrap;

$initial_tab = "\t";    # Tab before first line
$subsequent_tab = "";   # All other lines flush left

print wrap($initial_tab, $subsequent_tab, @text);
print fill($initial_tab, $subsequent_tab, @text);

$lines = wrap($initial_tab, $subsequent_tab, @text);
@paragraphs = fill($initial_tab, $subsequent_tab, @text);
## Options

- `$Text::Wrap::columns` — Line width at which to wrap (default: 76). Every resulting line has length ≤ `$columns - 1`.
- `$Text::Wrap::break` — Pattern to determine word boundaries. Default: `'\s'`. Can be a string like `'[\s:]'` or a precompiled regexp.
- `$Text::Wrap::unexpand` — If false, disables conversion of spaces back to tabs in output (default: true).
- `$Text::Wrap::tabstop` — Number of characters per tab stop (default: 8).
- `$Text::Wrap::separator` — String to replace all newlines with (e.g., `"|"`). Overrides default `"\n"`.
- `$Text::Wrap::separator2` — String to replace added newlines only (preserves existing newlines).
- `$huge` — Behavior for words longer than `$columns`. Values: `'wrap'` (default) breaks at column, `'die'` calls `die()`, `'overflow'` leaves intact.
- `$Text::Wrap::SUBVERSION` — Read-only; `"modern"` for Perl 5.10+, `"old"` for older Perls.

## Examples

perl
print wrap("\t", "", <<END);
This is a bit of text that forms
a normal book-style indented paragraph
END
# Result: "     This is a bit of text that forms\na normal book-style indented paragraph\n"
perl
$Text::Wrap::columns = 20;
$Text::Wrap::separator = "|";
print wrap("", "", "This is a bit of text that forms a normal book-style paragraph");
# Result: "This is a bit of|text that forms a|normal book-style|paragraph"
## See Also

- [Text::WrapI18N](http://localhost/phpMan.php/perldoc/Text%3A%3AWrapI18N/markdown) — for correct handling of East Asian half- and full-width characters
- [Text::Format](http://localhost/phpMan.php/perldoc/Text%3A%3AFormat/markdown) — for more detailed controls