@userlist = $rootNode->get_node_list('user'); foreach $userlist (@userlist) { $name = $userlist->get_attrib('name'); $email = $userlist->get_attrib('email'); $fullname = $userlist->get_attrib('fullname'); # Look for a case-insensitive match of the 'name' from the # config file to either the full username or the username # without the NT domain. if (((lc $name) eq (lc $full_username)) || ((lc $name) eq (lc $bare_username))) {
I have not seen this issue, but I think you are correct on the issue being the email_map. If you peruse the PM, iwov_emailmap.pm you will see that it iterates through the list doing a compare. @userlist = $rootNode->get_node_list('user'); foreach $userlist (@userlist) { $name = $userlist->get_attrib('name'); $email = $userlist->get_attrib('email'); $fullname = $userlist->get_attrib('fullname'); # Look for a case-insensitive match of the 'name' from the # config file to either the full username or the username # without the NT domain. if (((lc $name) eq (lc $full_username)) || ((lc $name) eq (lc $bare_username))) { That works great for a small set (couple hundred or less) of email addresses. But it is a brute force method.I do not know if one could convert this to a hash and make it faster, but a regex would certainly be faster. If you are comfortable in Perl you can play with it.Maybe someone else may look at it as well.Andy
open (CFG, $email_map_file) || die "Cannot open $email_map_file: $!\n";$xml = join ("", <CFG>);close CFG;
open(CFG, '<', $email_map_file) || die "Cannot open $email_map_file: $!\n";$xml = do { local $/; <CFG> };close CFG;
Benchmark: timing 1000 iterations of iwov, slurp... iwov: 3 wallclock secs ( 2.67 usr + 0.13 sys = 2.80 CPU) @ 357.53/s (n=1000) slurp: 0 wallclock secs ( 0.16 usr + 0.11 sys = 0.27 CPU) @ 3773.58/s (n=1000) (warning: too few iterations for a reliable count)
Benchmark: timing 1000 iterations of iwov, slurp... iwov: 8 wallclock secs ( 7.97 usr + 0.23 sys = 8.20 CPU) @ 121.91/s (n=1000) slurp: 1 wallclock secs ( 0.45 usr + 0.13 sys = 0.58 CPU) @ 1730.10/s (n=1000)
Another place you lose time is with the reading in of the email_map.cfg file:open (CFG, $email_map_file) || die "Cannot open $email_map_file: $!\n";$xml = join ("", <CFG>);close CFG;I'd suggest changing it to:open(CFG, '<', $email_map_file) || die "Cannot open $email_map_file: $!\n";$xml = do { local $/; <CFG> };close CFG; - I just threw together a quick benchmark script for these two routines, and put roughly 500 entries into my email_map.cfg and got back the following results for a run of 1000 tries:Benchmark: timing 1000 iterations of iwov, slurp... iwov: 3 wallclock secs ( 2.67 usr + 0.13 sys = 2.80 CPU) @ 357.53/s (n=1000) slurp: 0 wallclock secs ( 0.16 usr + 0.11 sys = 0.27 CPU) @ 3773.58/s (n=1000) (warning: too few iterations for a reliable count) - So I bumped the # of entries up to about 1500 and the numbers changed:Benchmark: timing 1000 iterations of iwov, slurp... iwov: 8 wallclock secs ( 7.97 usr + 0.23 sys = 8.20 CPU) @ 121.91/s (n=1000) slurp: 1 wallclock secs ( 0.45 usr + 0.13 sys = 0.58 CPU) @ 1730.10/s (n=1000) So I think you could get some significant time savings by just changing that one piece of code.
open(CFG, '<', $email_map_file) || die "Cannot open $email_map_file: $!\n";$xml = do { local $/; };close CFG;
#!c:\interwoven\iw-home\iw-perl\bin\iwperlmy $xml = qq{<emailConf><user name="aknipp" fullname="Andy Knipp" email="aknipp\@myco.com"/><user name="user1" fullname="User One" email="user1\@myco.com"/><user name="user2" fullname="User Two" email="user2\@myco.com"/><user name="user3" fullname="User Three" email="user3\@myco.com"/><user name="user4" fullname="User Four" email="user4\@myco.com"/><user name="domain\\user5" fullname="User Five" email="user5\@myco.com"/><user name="domain\\user6" fullname="User Six" email="user6\@myco.com"/><user name="domain\\user7" fullname="User Seven" email="user7\@myco.com"/></emailConf>};my $find = "aknipp";$xml =~ m|name=\"$find\" fullname=\"(.*?)\" email=\"(.*?)\"/>|i;$fullname=$1;$email=$2;print "Find - $find Fullname - $fullname email - $email\n";$find = "domain\\user7";$xml =~ m|name=\"$find\" fullname=\"(.*?)\" email=\"(.*?)\"/>|i;$fullname=$1;$email=$2;print "Find - $find Fullname - $fullname email - $email\n";exit(0);
$xml =~ m|name[ \t]*=[ \t]*[\"\']$find[\"\'][ \t]+fullname[ \t]*=[ \t]*[\"\'](.*?)[\"\'][ \t]+email[ \t]*=[ \t]*[\"\'](.*?)[\"\'][ \t]*/>|i;
#!c:\interwoven\iw-home\iw-perl\bin\iwperlmy $xml = qq{<emailConf><user name ="aknipp" fullname ='Andy Knipp' email = "aknipp\@myco.com" /><user name="user1" fullname="User One" email="user1\@myco.com"/><user name="user2" fullname="User Two" email="user2\@myco.com"/><user name="user3" fullname="User Three" email="user3\@myco.com"/><user name="user4" fullname="User Four" email="user4\@myco.com"/><user name="domain\\user5" fullname="User Five" email="user5\@myco.com"/><user name="domain\\user6" fullname="User Six" email="user6\@myco.com"/><user name="domain\\user7" fullname="User Seven" email="user7\@myco.com"/></emailConf>};my @users = ("aknipp","user1","user4","domain\\user6");foreach $find (@users) {if ($find =~ m|(.*)\\(.*)|){ $domain = $1; $user = $2; $xml =~ m|name[ \t]*=[ \t]*[\"\']$domain\\$user[\"\'][ \t]+fullname[ \t]*=[ \t]*[\"\'](.*?)[\"\'][ \t]+email[ \t]*=[ \t]*[\"\'](.*?)[\"\'][ \t]*/>|i; $fullname = $1; $email = $2; } else { $xml =~ m|name[ \t]*=[ \t]*[\"\']$find[\"\'][ \t]+fullname[ \t]*=[ \t]*[\"\'](.*?)[\"\'][ \t]+email[ \t]*=[ \t]*[\"\'](.*?)[\"\'][ \t]*/>|i; $fullname = $1; $email = $2; }print "Find - $find Fullname - $fullname email - $email\n";}exit(0);
OK, so here is one with the domains working. If you feel adventurous, try to replace the iwov_emailmap.pm code with something like this.
A limitation you probably have to spell out is that you assumed a fixed order of user Tag attributes
Good point. I assume you *could* do a regex that is order independent, but mine is ugly enough, I cannot imagine how bad that one would look.
Cool fish, thanks. I forgot about using the \s. I have used the \Q before, but it was not working in this example because I did not know to use the \E. I had to dig through the ORA regex book to see what this was doing.BTW, what does the x do at the end of the regex ?
Strange, I ran this myself and it worked for the user without the domain, but not with the domain. I did have to escape the @ sign and tried to do the same with the backslash. That was why I used 2 regexes instead of 1.I could not get it to work with both.Find - aknipp Fullname - Andy Knipp email - aknipp@myco.comUnable to find fullname and email for 'domain\user7'