#!/usr/bin/perl
use strict;
use warnings;
my $spaces=0;
while (chomp(my $line=<>)) {
$line =~ s/^\s+|\s+$//g;
if ($line =~ /}/) {
$spaces-=4;
}
my $padded = sprintf("%${spaces}s",$line);
print "$spaces:$padded\n";
if ($line =~ /{/) {
$spaces+=4;
}
}
####
#!/usr/bin/perl
my $blah=1;
my $blah2=3;
if ($blah1 =~ blah2) {
then do this;
and if not {
then do this as well;
and then this {
blah;
}
return it;
}
talk
}
####
0:#!/usr/bin/perl
0:
0:my $blah=1;
0:my $blah2=3;
0:
0:if ($blah1 =~ blah2) {
4:then do this;
4:and if not {
8:then do this as well;
8:and then this {
12: blah;
8: }
8:return it;
4: }
4:talk
0:}