/usr/src/perl/pod/perlfaq4/How_do_I_expand_tabs_in_a_string.pod

How do I expand tabs in a string?

You can do it the old-fashioned way:

    1 while $string =~ s/\t+/' ' x (length($&) * 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);