-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtool_1.pl
45 lines (41 loc) · 1.06 KB
/
tool_1.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl -w
#@date 2014/03/21
#@version 1.0
use strict;
use warnings;
my $writeFileName = "result.txt";
#recursively traverse all files
sub traverseDir{
my $dirName = shift ;
opendir( my $dir , $dirName) or die "unable to open this directory $!\n";
while( my $fileName = readdir( $dir )){
if ( $fileName =~ /.*(_macro_log)\.(xml)/ ){
$dirName =~ s/(\/\.)//g;
my $path = "$dirName/$fileName";
print "path: $path\n";
open( FILE , "<$path" ) or die "file open failed $!\n";
while( <FILE> ){
my $linenum = -1;
$linenum = $2 if $_ =~ /.*(<linenum>)(\d+)(<\/linenum>).*/g;
next if $linenum == -1 ;
my $writeContent = $path."\t\t".$linenum;
print "content :: $writeContent\n";
open( DATA, "+>>$writeFileName")
or die "unable to open $writeFileName file $!\n";
print DATA "$writeContent\n";
close( DATA );
}
close( FILE );
}
if( -d "$dirName/$fileName"){
&traverseDir( "$dirName/$fileName");
}
}
close( $dir );
return $dirName;
}
if( $ARGV[0]){
traverseDir( $ARGV[0]);
}else{
&traverseDir( "." );
}