I need a detab function written in perl. [...] How about a one liner? :-)
This isn't even ugly:
perl -pe '$spacing = 8; 1 while s/\t/" " x ($spacing - length($`) % $spacing)/e;'
(Amazing! The only other language I know of that can do this in one
line is Snobol!)
However, the apparently equivalent program
perl -pe '$spacing = 8; s/\t/" " x ($spacing - length($`) % $spacing)/eg;'
doesn't work, apparently because s///g doesn't work exactly as I
expect. I expect it to perform each search and replacement, and then
start searching again in the modified string. It appears (if I insert
a strategic print) that the successive searches are done in the
original string, and all modifications are in a copy of it. (Is this
what we really want? Is this documented?)
Dale Worley Compass, Inc. wor...@compass.com
--
It is easier to get forgiveness than permission.
I don't know if it's what you want, but it's what you get. :-)
It's documented in The Book, somewhere...
The substitution code is a bit touchy, and if I fiddle with it much
I'll end up rewriting it, which I don't want to do right now.
Larry