1 #!/usr/bin/perl
2
3
4 # create a direction to save coding files
5 $code = "./coding";
6 if(-d $code)
7 {
8 print "Direction $code already existed. Remove it\n";
9 `rm -rf $code`;
10 }
11 print "create $code direction\n";
12 `mkdir $code`;
13
14
15 #Find orig file and modifed file for mkdir diff file
16 foreach $orig_file_name (`find . -name "*.orig" -size +0c`){
17 chomp ($orig_file_name);
18 $file_name = substr($orig_file_name, 0, index($orig_file_name, ".orig"));
19 if(-f $file_name)
20 {
21 $diff_file_name = $file_name.".diff";
22 print "find $file_name\n";
23 print "find $orig_file_name\n";
24 print "create $diff_file_name\n";
25 `diff -c $orig_file_name $file_name > $diff_file_name`;
26
27 @dTree = split(/\//, $orig_file_name);
28 $a = @dTree;
29 $d = $code;
30 for($i = 1; $i < $a - 1; $i++)
31 {
32 $d = "$d/$dTree[$i]";
33 `mkdir $d`;
34 }
35 print "create $d\n";
36 print "copy $file_name, $orig_file_name, $diff_file_name to $d\n";
37 `cp $file_name $d`;
38 `cp $orig_file_name $d`;
39 `cp $diff_file_name $d`;
40 }