in reply to Conditionally converting tabs to spaces
Enjoy! Update: This code will not work of a field is longer than 8 chars, but the following will:my $tab = 8; while ( <DATA> ) { chomp; my $fixed = join '', map { $_ . ' 'x($tab-length) } split /\t/; print "$fixed\n"; } __DATA__ hello 57 *45 78 there *57 93 *83 dude 78 23 *45
ps. I don't think any of the other responses take that for account either, but if I'm wrong, I'll retract that.
my $fixed = join '', map { $_ . ' 'x(((int(length()/$tab)+1)*$tab)-len +gth) } split /\t/;
-- Casey
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Conditionally converting tabs to spaces
by chromatic (Archbishop) on Jul 04, 2000 at 03:19 UTC |