in reply to Efficient way to verify scalar contents
I see it as a rules matrix to be checked.
I'd take
$index= min( int(length /4), 5 )
And an array of arrays @rules for lookup.
The rules array would contain subs which all must return true for the password to pass.
Like $letter = sub { /[a-z]/i }
(This will test against $_ )
So $rules[3] = [ $letter, $number ]
$rules[1] = [ $forbidden ]
All you need to do now is too loop over all rules and fail if one entry returns false.
HTH! :)
PS instead of code refs one might also store regex refs with qr//.
But why blocking the way to more complicated rules?
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Efficient way to verify scalar contents
by x_stream3m (Initiate) on Jun 22, 2020 at 05:15 UTC | |
by perlfan (Vicar) on Jun 22, 2020 at 05:48 UTC | |
by LanX (Saint) on Jun 22, 2020 at 11:40 UTC | |
by LanX (Saint) on Jun 22, 2020 at 12:04 UTC | |
by haukex (Archbishop) on Jun 22, 2020 at 13:17 UTC | |
by LanX (Saint) on Jun 22, 2020 at 13:22 UTC |