Commits

Palmer, 2E0EOL committed 4e8aae1

Improve the internal _Debug function

Comments (0)

Files changed (1)

 					$newParams{'Dir'} = $fullPath;
 					$self->Scan(%newParams);
 				} else {
-					$self->_Debug(sprintf(
+					$self->_Debug(
 						'Skipped %s (not recursing into subdirectories)',
 						$fullPath
-					));
+					);
 					next; # Skip directories where not recursing
 				}
 			} else {
 #----------------------------------------------------------------------------
 sub _Debug($$)
 {
-	my ( $self, $Msg ) = @_;
+	my ( $self, $Msg ) = ( shift, shift );
 	if ( $self->{_debug} ) {
-		die(sprintf('Debug handle is %s', $self->{_debug}));
+		$Msg .= "\n";
+		my $d = $self->{_debug};
+		my $r = ref($d);
+		if ( $r ) {
+			if ( $r eq 'CODE' ) {
+				$r->($Msg, @_);
+			}
+		} else {
+			if ( index($d, '*') == 0 ) {
+				printf($d $Msg, @_);
+			} else {
+				printf(main::STDERR $Msg, @_);
+			}
+		}
 	}
 }
 #----------------------------------------------------------------------------
 use warnings;
 use diagnostics;
 
+use Getopt::Std;
+
 use constant TRUE  => (1);
 use constant FALSE => (0);
 use constant EXIT_FAILURE => (1);
 sub Main()
 {
 	my $dirScan = DirScan->new(Debug => *STDERR);
-	$dirScan->Scan(Dir => '.', Recurse => TRUE());
+	$dirScan->Scan(Dir => '.', Recurse => FALSE());
 	return EXIT_SUCCESS();
 }
 #----------------------------------------------------------------------------