Changeset 25944

Show
Ignore:
Timestamp:
12/05/08 15:40:58 (5 years ago)
Author:
tokuhirom
Message:

better impl

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/misc/ppish.pl

    r25942 r25944  
    66use Perl6::Say; 
    77 
    8 my $level = -1; 
     8my $level = 0; 
     9 
     10sub display { 
     11    my $elem = shift; 
     12    my $ws = ' ' x ($level*3); 
     13    my $klass = ref $elem; 
     14    my $comment = $elem->isa('PPI::Token::Whitespace') ? '' : " # $elem"; 
     15    say join('', $ws, $klass, $comment); 
     16} 
    917sub dumpit { 
    1018    my $elem = shift; 
    1119    if ($elem->can('children')) { 
     20        display($elem); 
    1221        for my $child ($elem->children) { 
    1322            $level++; 
     
    1625        } 
    1726    } else { 
    18         my $ws = ' ' x (($level-1)*3); 
    19         my $klass = ref $elem; 
    20         my $comment = $elem->isa('PPI::Token::Whitespace') ? '' : " # $elem"; 
    21         say join('', $ws, $klass, $comment); 
     27        display($elem); 
    2228    } 
    2329}