MOON
Server: Apache
System: Linux vps.thepromohut.com 2.6.18-398.el5 #1 SMP Tue Sep 16 20:51:48 EDT 2014 i686
User: caretrak (507)
PHP: 5.2.10
Disabled: NONE
Upload Files
File: //scripts.20110601.041516.15411/comparegdbm
#!/usr/bin/perl
# cpanel - comparegdbm                            Copyright(c) 2009 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use Fcntl     ();
use GDBM_File ();

if ( $ARGV[0] eq '--bincheck' ) {
    print "BinCheck ok\n";
    exit();
}

if ( defined $ARGV[0] && -e $ARGV[0] && defined $ARGV[1] && -e $ARGV[1] ) {
    my %GDBM_FILE_A;
    my $ta = tie %GDBM_FILE_A, 'GDBM_File', $ARGV[0], &GDBM_File::GDBM_READER, 0644;
    die "$ARGV[0] does not appear to be a valid GDBM file." if !$ta;

    my %GDBM_FILE_B;
    my $tb = tie %GDBM_FILE_B, 'GDBM_File', $ARGV[1], &GDBM_File::GDBM_READER, 0644;
    die "$ARGV[1] does not appear to be a valid GDBM file." if !$tb;

    my %b_copy = (%GDBM_FILE_B);    # we need a copy since you can't delete() from this tied-readonly hash

    # does A exist in B
    for my $k ( sort keys %GDBM_FILE_A ) {
        if ( !exists $GDBM_FILE_B{$k} ) {
            print "$ARGV[1] is missing “$k”\n";
        }
        else {
            delete $b_copy{$k};     # we've seen it
        }
    }

    # any keys in B that were not in A
    for my $y ( sort keys %b_copy ) {
        print "$ARGV[1] has additional “$y”\n";
    }
}
else {
    print "This tool is for comparing the contents of 2 GDBM files.\n";
    print "Example: $0 /var/cpanel/locale/themes/x3/en.gdbm /var/cpanel/locale/themes/x3/fr.gdbm\n\n";
    print "Usage: $0 [gdbm file a] [gdbm file b]\n";
}