Created
June 22, 2009 01:38
-
-
Save jaymcgavren/133760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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