<?xml version="1.0" encoding="windows-1252"?>
<node id="1014928" title="Re: Password (pseudo)casual" created="2013-01-23 10:19:42" updated="2013-01-23 10:19:42">
<type id="11">
note</type>
<author id="5348">
Corion</author>
<data>
<field name="doctext">
&lt;p&gt;Your generator cannot generate a password with the letters &lt;c&gt;a&lt;/c&gt;, &lt;c&gt;b&lt;/c&gt; or &lt;c&gt;c&lt;/c&gt; due to the &lt;c&gt;+3&lt;/c&gt; when selecting the random letter. See [doc://rand], which already returns a number in the range from &lt;c&gt;0..$len&lt;/c&gt;.&lt;/p&gt;
&lt;p&gt;The variable &lt;c&gt;$len&lt;/c&gt; is named wrong - it has the last index of &lt;c&gt;@lett&lt;/c&gt;, not the number of elements in the array. This means that your password generator would never output the last element from &lt;c&gt;@lett&lt;/c&gt; if it weren't for the &lt;c&gt;+ 3&lt;/c&gt; from the previous step. I would use:&lt;/p&gt;
&lt;c&gt;
$len = @lett;
&lt;/c&gt;
&lt;p&gt;... which assigns to &lt;c&gt;$len&lt;/c&gt; the number of elements in &lt;c&gt;@lett&lt;/c&gt;.&lt;/p&gt;
&lt;p&gt;Other than that, using double quotes in a simple assignment is weird unless you have a special reason to do so - and if you are starting with Perl just now, those special reasons ("stringification") are still far away. So, no assignment should be of the form&lt;/p&gt;
&lt;c&gt;
    $foo = "$bar";
&lt;/c&gt;
&lt;p&gt;and always of the form&lt;/p&gt;
&lt;c&gt;
    $foo = $bar;
&lt;/c&gt;</field>
<field name="root_node">
1014922</field>
<field name="parent_node">
1014922</field>
</data>
</node>
