in reply to RE: RE: (Ovid) Re: General quesion
in thread General quesion
My question wasn't clear. I know that rand() returns a number between 0 and it's argument. But my point was, it returns a decimal; i.e. 3.14159, 25.70098, .00001, etc. Does perl automatically round the number down(or take the integer portion)? For eaxample, here is my code:
my $lRandomPassword = ''; my $lMaxLength = 10; my $length; my $lRand; my @lKeySpace = ('A'..'Z', 'a..z', 0..9); my $lKeySpaceSize = scalar(@lKeySpace); for ($length = 0; $length < $lMaxLength; $length++) { $lRand = int(rand($lKeySpaceSize)); $lRandomPassword .= $lKeySpace[$lRand]; }; $lRandomPassword;
Yes, I know the code is overly verbose, but the important question for me is, could I safely get rid of the int() call? Does perl take the integer portion of an array index?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE: RE: (Ovid) Re: General quesion
by KM (Priest) on Aug 08, 2000 at 22:45 UTC | |
by tye (Sage) on Aug 08, 2000 at 23:27 UTC | |
by KM (Priest) on Aug 08, 2000 at 23:32 UTC | |
by tye (Sage) on Aug 08, 2000 at 23:58 UTC | |
by KM (Priest) on Aug 09, 2000 at 00:04 UTC |