in reply to Comparing strings to reduce excess results
Sorry, but I don't understand what you're trying to do with the next two lines. The if would never match. Here is what you're doing:foreach $node (keys(%current)) { if ($current{$node} eq "created") { foreach $node2 (keys(%prior)) { while ($node2 =~ m/\/.+(\S)/) {
Here is my solution for your approach:
(There are shorter variants, but we want to stay easy and readable.)for $node (keys(%current)) { if ($current{$node} eq "created") { ++$Created; } elsif ($current{$node} eq "deleted") { ++$Deleted; } }
This runs through the first hash and looks if the same entry exists in the prior hash. If there is no such hash key, it counts the node as new.for $node (keys(%current)) { defined($prior{$node}) or ++$Created; } for $node (keys(%prior)) { defined($current{$node}) or ++$Deleted; }
I still don't understand what you were trying to do with your source, maybe it's still too early morning here. :-) It would be good for helping you, if you could add some more text and/or comments.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing strings to reduce excess results
by Anonymous Monk on Sep 15, 2009 at 07:24 UTC | |
by Sewi (Friar) on Sep 15, 2009 at 07:29 UTC |