It appears to be the index of the check based on length of the supplied password. You have 4 valid conditions that lead to additional checks; the 5th one is always invalid. Indexes 0, 1, 2, and 3 elements of the array of subroutine references he suggests will call the function appropriate for the length.
when ($_ >= 8 && $_ <= 11) # $index here is min( 2, 5), so 2
when ($_ >= 12 && $_ <= 15) { # $index here is min( 3, 5), so 3
when ($_ >= 16 && $_ <= 19) { # $index here is min( 4, 5), so 4
when ($_ >= 20) { # $index here is min( 5+,5), so alw
+ays bounded at 5
TBH it's not clear enough to make great sense to me, but he appears to be suggesting that you put your ranges into buckets based on the formula he gave; for a length of 20 or more, you're always going to fall into bucket 5 (or perhaps element 3) of your array of checks.
This is actually a pretty good way to determine a bucket, so then you can have an array of checks; or to make it more clear, a hash:
my %check_dispatch = (
2 => sub { ... }, # or better, define in named subs and, => \&check1
+, etc
3 => sub { ... },
4 => sub { ... },
5 => sub { ... },
);
my $pw = $_;
my $index = min( (length $pw)/4, 5);
if ($check_dispatch{$index} and 'CODE' eq ref $check_dispatch{$index})
+ {
die if not $check_dispatch{$index}->($pw);
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.