root/pretty.pl

Revision 1, 507 bytes (checked in by sascha, 3 years ago)

foobar

Line 
1#!/usr/bin/perl
2
3use IO::Handle;
4STDOUT->autoflush;
5use strict;
6my $indent = 0;
7my $line;
8while(defined ($line = <STDIN>)) {
9  my $ix = 0;
10  for my $ix (0 .. length($line)) {
11    my $char = substr($line, $ix, 1);
12    if (substr($line, $ix, 1) eq '<') {
13      print '<';
14      $indent += 2;
15      print "\n";
16      print " " x $indent;
17    } elsif (substr($line, $ix, 1) eq '>') {
18      $indent -= 2;
19      print "\n";
20      print " " x $indent;
21      print '>';
22    } else {
23      print $char;
24    }
25  }
26}
27
Note: See TracBrowser for help on using the browser.