in reply to Balancing Coding Time And Code Quality

The obvious (to me) modest improvement is to change the main loop so that you're only keeping in %master those things that you need to delete from %slave later (since that's all you're doing with it, anyway). For clarity, you should rename %master to %common.
my (%common, %slave); %slave = map {chomp; $_ => undef} <SLAVE>; while ( <MASTER> ) { chomp; if (exists $slave{$_}) { $common{$_} = undef } else { print "$_ exists on master but not slave\n" } } delete @slave{ keys %common }; print "$_ exists on slave but not master\n" for keys %slave;

The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re: Re: Balancing Coding Time And Code Quality
by Limbic~Region (Chancellor) on Dec 04, 2003 at 22:55 UTC
    Roy Johnson,
    Thanks - your suggestion lead to getting rid of the %common/master hash all together
    my %slave = map {chomp; $_ => undef} <SLAVE>; while ( <MASTER> ) { chomp; exists $slave{$_} ? delete $slave{$_} : print "$_ exists on master + but not slave\n"; } print "$_ exists on slave but not master\n" for keys %slave;
    Cheers - L~R