On Mar 21, 2006, at 4:18 PM, Eric Bergman wrote:

Is there a simple way in BBEdit to convert a file with variable- length lines (and a hard return on each one) so that all lines have a specific length? In other words, I want to pad lines out to some column with zeros.


With a Unix Filter.

This will pad all your lines to 80 characters (it will also chop off any characters past #80 if a line is longer, if you don't want to do that remove the line containing the "$= substr($_,0,80)".

To change the padding length, just change the three 80's to whatever you want to pad to.

#!/usr/bin/perl -w

my $l;
while(<>) {
chomp($_);
$_ = substr($_,0,80);
$l = length($_);
($l< 80) ? (print "$_", " " x (80-$l) ."\n") : (print "$_\n");
}


--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to