Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Balancing Coding Time And Code Quality

by Roy Johnson (Monsignor)
on Dec 04, 2003 at 22:01 UTC ( #312337=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://312337]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2018-06-22 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (124 votes). Check out past polls.

    Notices?