Skip to content

Instantly share code, notes, and snippets.

@jaymcgavren
Created June 22, 2009 01:38
Show Gist options
  • Save jaymcgavren/133760 to your computer and use it in GitHub Desktop.
Save jaymcgavren/133760 to your computer and use it in GitHub Desktop.
#!/opt/local/bin/perl
#Get command line options.
$wrap_column = $ARGV[0] || 60;
#Set up text wrap options.
use Text::Wrap;
use Text::Tabs;
$Text::Wrap::columns = $wrap_column;
#Process each input line.
LINE: while (<STDIN>) {
#Clean up line.
chomp;
#Get existing indentation to use on subsequent lines.
if (/^(\s+)/) {$indentation = $1}
else {$indentation = undef}
#Wrap text and print.
print expand(wrap(undef, $indentation, $_)) . "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment