It's a Perl application. But has a bit of JavaScript included. The following is a JavasScript function. But given that Perl, and JavaScript are so similar, in so many ways. I was hoping you all might indulge me.
'function' : function (fieldObj,option) { var v = fieldObj.value = fieldObj.value.toString().replace(/\s/g,'').toUpperCase(); if (!v) { return false; } var bm = v.match(/^JM-\d+-\S{4}[1-9Zz]{6}$/); if ( v.match(/^JM-\d+-\S{4}[1-9Zz]{6}$/) ) { return true; } var map = {}; var dv = 0; $w('A B C D E F G H J K L M N P Q R T U V W Y 3 4 6 7 8 9').each( function(d){ map[d] = dv++; } ); var chars = v.toArray().reverse(); var check = chars.shift(); chars = chars.findAll(function(d){ return map[d] != null }); if (chars.length != 19) { return false; } var totalVal = 0; var flip = 1; chars.each(function(c){ var posVal = map[c]; if ( !(flip = !flip) ) { posVal *=2 } while(posVal){ totalVal = totalVal + (posVal % 10); posVal = Math.floor(posVal/10); } }); return ( check == ( 10 - totalVal % 10 ) % 10 ); }
It's a form field validation function, and requires certain input. But I'm afraid it's a bit over my head, and was hoping one of the brighter Monks here, might help me better understand it.
It seems quite clever, but either my math, or my code tracing isn't quite up to snuff, on this one.
Thank you for all your time, and consideration.¡λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH
In reply to I'm struggling with a function, and hoping for some insight -- not strictly Perl by taint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |