in reply to Where's the leak?
sub search { my ($file, $searchString) = @_; local *F; open(F, "<", $file) or return 0; binmode(F); my $nbytes = read(F, my $window, 2 * BLOCKSIZE); while ( $nbytes > 0 ) { if ( $window =~ m/$searchString/ ) { close(F); return 1; } $nbytes = read(F, my $block, BLOCKSIZE); last if $nbytes == 0; substr($window, 0, BLOCKSIZE) = ''; $window .= $block; } close(F); return 0; }
And you've got another problem solved by the wisdom of the monks.if(search($file, $searchString)) { print "\tFound: $file\n"; foreach(@dir) { if(/^.*?\s+([A-Z]{1}$numSet\.\S{3})$/) { my $found = join('\\', ($dirPath, $1)); print "\tFound: $found\n"; } } }
|
|---|