Tabs to spaces

From JmPm

(Difference between revisions)
Jump to: navigation, search
(from old wiki)
m (Protected "Tabs to spaces": spam [edit=autoconfirmed:move=autoconfirmed])

Revision as of 12:42, 14 March 2007

sub Tab2Space {
   my ($line) = @_;
   $line =~ s/^\t/        /;   # 8 leading spaces if initial tab
   while ($line =~ s/^([^\t]+)(\t)/$1 . ' ' x (8 - length($1) % 8)/e) {
   }                           # replace each tab with right num of spaces
   return $line;
}
Personal tools