Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Balancing Coding Time And Code Quality

by Roy Johnson (Monsignor)
on Dec 04, 2003 at 22:01 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://312337]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-26 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found