Hm. Some flaws, like forcing a particular pattern, not using printable chars outside of A-Za-z0-9, etc. Mostly, though, reinventing a well-solved wheel.
use Crypt::RandPasswd; print 'Password: ',Crypt::RandPasswd->chars(9,9), "\n";
The above generates a 9-char random password using Crypt::RandPasswd. If limiting the chars used, etc, is desired, read the POD for that module, as it explains how to restrict character space and other features.

If you're on a UNIX system, importing Crypt::Random will give you access to a better PRNG (using /dev/random or the EGD) that you can hand off to Crypt::RandPasswd. If you're not on UNIX, you can either install a version of EGD for your platform, or try using Crypt::Random::ISAAC - secure random number generator (which, admittedly, is something I wrote for solving the cryptographic randomness issue in pure Perl). EGD (or /dev/random) with Crypt::Random is by far the better choice, if it is available to you (better tested, more mature, etc.)

Larry Wall is Yoda: there is no try{}
The Code that can be seen is not the true Code

In reply to Re: Random Password Generator by radiantmatrix
in thread Random Password Generator by satz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.