<?xml version="1.0" encoding="windows-1252"?>
<node id="204199" title="Re: How to replace Tab with spaces not altering postion" created="2002-10-10 11:11:10" updated="2005-08-13 12:29:12">
<type id="11">
note</type>
<author id="46495">
petral</author>
<data>
<field name="doctext">
&lt;code&gt;
&gt; perldoc -q tabs
Found in /usr/local/lib/perl5/5.6.1/pod/perlfaq4.pod
  How do I expand tabs in a string?

      You can do it yourself:

  1 while $string =~ s/\t+/' ' x (length($&amp;) * 8 - length($`) % 8)/e;

      Or you can just use the Text::Tabs module (part of the standard perl distribution).

  use Text::Tabs;
  @expanded_lines = expand(@lines_with_tabs);

&gt; 
&lt;/code&gt;
and this from perlop:&lt;code&gt;
   Occasionally, you can't use just a `/g' to get all the changes to
   occur that you might want.  Here are two common cases:

      # put commas in the right places in an integer
      1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/g;

      # expand tabs to 8-column spacing
      1 while s/\t+/' ' x (length($&amp;)*8 - length($`)%8)/e;

&lt;/code&gt;
And this has been in the perl man page since perl1!&lt;code&gt;

	print "\et" x ($tab/8), ' ' x ($tab%8);	# tab over
&lt;/code&gt;

&lt;br&gt;&lt;br&gt;&amp;nbsp &lt;i&gt;p&lt;/i&gt;</field>
<field name="root_node">
203941</field>
<field name="parent_node">
203941</field>
</data>
</node>
