Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Password Generation and Module Multiplication

by merlyn (Sage)
on Nov 22, 2010 at 20:59 UTC ( [id://873041]=note: print w/replies, xml ) Need Help??


in reply to Password Generation and Module Multiplication

Just an aside... this seems overly complex:
[qw( . ! / \ - : ; " ' ? $ ^ & @ [ ] = + | < > % * ~ ) , qw/ ( ) /, ', +', '#'],
why didn't you just write:
[qw( . ! / \ - : ; " ' ? $ ^ & @ [ ] = + | < > % * ~ , # ( ) )],
since qw's can nest for those parens, or even something like:
[map chr, 32..47, 58..63, 123..126]
to really get all of the "other" characters.

-- Randal L. Schwartz, Perl hacker

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Replies are listed 'Best First'.
Re^2: Password Generation and Module Multiplication
by JavaFan (Canon) on Nov 22, 2010 at 22:14 UTC
    Or just use {} as delimiters, as they aren't allowed chars. However, I'd write it as:
    [split //, q{.!/\-:;"'?$^&@[]=+|>?%*~.#()}]
    which doesn't trigger silly warnings because of the use of ',' and '#' inside qw. Besides, qw to get individual characters looks so awkward.
Re^2: Password Generation and Module Multiplication
by Orsmo (Beadle) on Nov 22, 2010 at 22:11 UTC

    Fair enough on the complexity of the "other" characters line. It is spelled out with explicit characters specifically to make it easier to add or remove given characters from the list. At the time, I think I had some warning that came up with the nested parens. Unfortunately my memory is a bit vague on that point. Those may simply have due to been a typo at the time. I will say though that with the use of "use strict; use warnings;" I do get at least the following warning:

    Possible attempt to separate words with commas at test line X.

    I'm sure there are more elegant ways to write the list though, including your fine use of map chr.

      At the time, I think I had some warning that came up with the nested parens.
      Which is why, in general, I don't add "use warnings" to the code I write. Sometimes, it finds useful things, but the only time it triggers for me now, it's simply annoying.

      If you find yourself changing the code you write to be more obscure or hard to maintain because warnings are warning you, warnings have failed.

      -- Randal L. Schwartz, Perl hacker

      The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

        Per contra, I always specify:   use strict; use warnings; ... and if there is any exception to that rule, I will place a no warnings "foo"; directive thereafter.   (If the unwanted warnings occur only in a specific block of code, the directive is placed on that block of code, then countermanded... and descriptive comments abound.

        In my experience, the warnings are usually correct; sometimes even prescient.   Computers simply don’t “overlook” things like aging humans do.

        I have to agree here. "Possible..." warnings really should only be given where there is a trivial change needed to get the warning to shut up. In this case, I'd say the warning shouldn't trip when , is preceded by whitespace.
        --
        A math joke: r = | |csc(θ)|+|sec(θ)|-||csc(θ)|-|sec(θ)|| |
        Online Fortune Cookie Search
        Office Space merchandise

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://873041]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found