Listing 1: Excerpt From DirDiff.pl use strict; use Getopt::Long; # BEGIN CALLOUT A use vars qw( %Config $gFileCount $KILOBYTE $MEGABYTE $GIGABYTE $TERABYTE ); $TERABYTE = 1024 * ( $GIGABYTE = 1024 * ( $MEGABYTE = 1024 * ( $KILOBYTE = 1024 ) ) ); my %FileList; my %File; my %Size; # END CALLOUT A $| = 1; Configure( \%Config ); if( $Config{help} ) { Syntax(); exit; } # BEGIN CALLOUT B foreach my $DirNumber ( 1, 2 ) { $gFileCount = 0; CollectFileList( $Config{dir_path}->{$DirNumber}, \%FileList, $DirNumber, "." ); } print STDERR "\r", " " x 80, "\n"; PrintReport( \%FileList ); # END CALLOUT B # BEGIN CALLOUT C sub CollectFileList { my( $Path, $FileList, $Context, $RelativePath ) = @_; my( @DirList ); if( opendir( DIR, $Path ) ) { foreach my $Object ( readdir( DIR ) ) { next if( "." eq $Object || ".." eq $Object ); my $ObjectPath = "$Path\\$Object"; my $RelativeObjectPath = lc "$RelativePath\\$Object"; if( ++$gFileCount < 200 || $gFileCount % 100 ) { my $PrettyPath = sprintf( "%6d) %s", $gFileCount, AbbreviatePath( $ObjectPath, 70 ) ); print STDERR "\r" . "$PrettyPath" . " " x ( 79 - length( $PrettyPath ) ); } if( -d $ObjectPath ) { push( @DirList, $Object ) if( $Config{recurse_subdir} ); } else { $FileList->{$RelativeObjectPath}->{$Context} = ( $Config{dont_collect_file_length} ) ? undef: -s $ObjectPath; } } closedir( DIR ); } foreach my $Dir ( @DirList ) { CollectFileList( "$Path\\$Dir", $FileList, $Context, "$RelativePath\\$Dir" ); } } # END CALLOUT C sub PrintReport { # BEGIN CALLOUT D my( $FileList ) = @_; $gFileCount = 0; $~ = "Header"; write; $~ = "Data"; foreach my $Path ( sort( keys( %{$FileList} ) ) ) { foreach my $DirNumber ( 1, 2 ) { $File{$DirNumber} = ( exists $FileList->{$Path}->{$DirNumber} )? $Path : ""; $Size{$DirNumber} = $FileList->{$Path}->{$DirNumber} || 0; } # END CALLOUT D # BEGIN CALLOUT E if( $File{1} ne $File{2} || $Size{1} != $Size{2} ) { ++$gFileCount; foreach my $DirNumber ( 1, 2 ) { $File{$DirNumber} = sprintf( "%s (%s)", $File{$DirNumber}, FormatNumberPretty( $Size{$DirNumber} ) ) if( exists $FileList->{$Path}->{$DirNumber} ); } write; } # END CALLOUT E } }