View Single Post
Old Feb 15th, 2007, 1:43 AM   #1
TheMuffenMann
Newbie
 
Join Date: Jan 2007
Posts: 4
Rep Power: 0 TheMuffenMann is on a distinguished road
got lazy writing C code...alas! a perl script for formatting

well..usually i use hard tabs with a default width of 8, for writing C code, but recently i've adopted a 4 space indent width instead..there's no way in hell im gonna type 4 spaces for every level of indentation, so threw together a quick perl script (i'm actually quite new to perl as far as using it alot goes) so that i can be lazy and use hard tabs when coding, then run the source code through this script and have it indented right. anyways, here it is..it's quite small:

#!/usr/bin/perl

$^I = ".bak";

while (<>) {
    s/\t/    /g;
    print;
}
TheMuffenMann is offline   Reply With Quote