#!/usr/bin/perl -w
use strict;

my @tree = <*>;
foreach (@tree){
    &if;_a_tree($_);
}

sub if_a_tree{
    if(-d) {
        print "$_ is a dir\n";
        chdir $_;
        my @tree=<*>;
        foreach(@tree) {
            &if;_a_tree($_);
        }
        chdir "..";
    }
    if(-f){
        if($_ =~ /\.cc$/) {
            my $new_name = $_;
            $new_name =~ s/\.cc/\.cxx/;
            print "$new_name is a cpp file\n";
            rename($_, $new_name);
        }
        
    }
}