in reply to Re: Please Review First Program: Random Password Generator
in thread Please Review First Program: Random Password Generator

Hey thanks for taking the time to whip up that quick rendition of my script. You are correct, I never thought of doing it that way. It has much to do with my inexperience and much to do with my lack of creativity. However, as this is my first script, I wanted to make it a bit more complicated than it needed to be. I do realize that I could have created the same functionality without the subroutines, blocks, and whatnot, but I know those are vital for future more complex scripts. I wanted to get my hands dirty a bit.

I must say this. I like a lot of the things you have done here. Your use of split, printf, join, shuffle, and ternary are superb. I guarantee I will be refering back to this.

I do have a question for you though. in your split function you use q[ ... ] with symbols [ and ] in there. Why does that not cause a syntax error? (I did test that and it does indeed work fine...just curious as to why/how) And what does that #' comment at the line end mean to you?

Thanks again for the short lesson!

-- hakkum

...never forget the hakkum bakkum,
the hakkum bakkum never forgets...

Replies are listed 'Best First'.
Re^3: Please Review First Program: Random Password Generator
by BrowserUk (Patriarch) on Feb 04, 2011 at 07:06 UTC
    1. you use q[ ... ] with symbols [ and ] in there. Why does that not cause a syntax error?

      For the why I can only answer with a generic: because Perl's parser is (mostly :) well thought out and implemented.

      I assume that the parser must be doing a maximal munch at that point.

      The 'balanced quoting' facilities of Perl are one (of many) things that I really miss in other languages. They save so much mess & hassle with escaping stuff.

      Mind you, I abhor their overuse in Perl--eg. q[] instead of a simple ''--almost as much as I miss them when they aren't available.

    2. And what does that #' comment at the line end mean to you?

      That's simply a crutch for my editor's less capable syntax highlighting parser. It see's the single quote embedded in the construct and starts highlighting the following text as a string constant, but doesn't stop until it sees a second single quote.

      The comment prevents that erroneous highlighting from running on to subsequent lines.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      perlop: "Non-bracketing delimiters use the same character fore and aft, but the four sorts of brackets (round, angle, square, curly) will all nest".

      q[ ] ] # XXX q[ [ ] # XXX q[ [ ] ] # ok q[ [ ] [ ] ] # ok q[ [ [ ] ] ] # ok q( [ ) # ok q[ ( ] # ok