Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

some more points.

by jlistf (Monk)
on Aug 07, 2000 at 21:43 UTC ( [id://26615]=note: print w/replies, xml ) Need Help??


in reply to General quesion

you'll hear it eventually and get burned by it soon, so here it is:

use strict and use warnings.
this will force you to declare all your variables. eventually, this will come in very handy. its better to get started early before you get seriously burned later on.
some other notes:
  • you don't have to call srand. perl will do this for you.
  • the while loop can be turned into a for (1..8) loop. this will get rid of the $i control variable which does not do anything.

update (to Ovid): slowpoke. :)

Replies are listed 'Best First'.
RE: General question
by turnstep (Parson) on Aug 07, 2000 at 23:12 UTC

    > you don't have to call srand. perl will do this for you.

    Technically, only versions of perl 5.004 and higher will call srand for you. Also note that if you are using a pre-5.004 version, srand alone uses time as the seed, which is generally Not Very Random. It will probably do in this case. So calling srand explicitly is actually the safest, most portable way to do it. Or you could be really proper and call srand depending on the version of perl detected.

    Also, here is a simpler way to create a random string. Just has to use this one today, actually. (Yes, it's in the Perl Cookbook, but I came up with it on my own :p)

    @letters = ('A'..'Z','a'..'z',0..9,qw(! # $ % ^ | _)); $randomstring = join("", @letters[map {rand @letters} (1..8)]);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://26615]
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: (2)
As of 2024-04-20 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found