Posts Tagged ‘format’

Code formating script

Posted: 4th April 2013 by Babar Shafiq in Programming, System Administration, Tips
Tags: , , ,

#!/usr/bin/perl -w my $ifile = shift; my $blank = 0; my $indent = 2; open(IFILE, “$ifile”) or die “Cannot open $ifile\n”; while(my $line = ) { if($line =~ /^\s*else/i or $line =~ /^\s*end/i ) { #reduce indent before xxx $blank = $blank – 2; } if($blank > 0) { print ” ” x $blank; #print […]