@chars the same as ($#chars) ? 
Author Message
 @chars the same as ($#chars) ?

In the little program below, lines 6 and 7 appear to be equivalent.

reading to clarify this point.

TIA

Owen

-----------------------------------------------------------

#!/usr/bin/perl -w



#$salt = $chars[rand($#chars)] . $chars[rand($#chars)]; # Line 7

$encrypted = crypt($password, $salt);
print "$encrypted\n";



Tue, 04 Nov 2003 17:32:54 GMT  
 @chars the same as ($#chars) ?
Owen Cook wrote in comp.lang.perl.misc:
Quote:
} In the little program below, lines 6 and 7 appear to be equivalent.

} reading to clarify this point.

[snip]






--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/



Tue, 04 Nov 2003 17:36:04 GMT  
 @chars the same as ($#chars) ?

Quote:
> In the little program below, lines 6 and 7 appear to be equivalent.

Don't jump to conclusions.  The equivalence of programs that depend
on random numbers is hard to assess.

Quote:

> reading to clarify this point.

You should read about array variables in perlvar.

$#chars is the index to the last element of the array.  There's
a difference of (usually) 1.

[most of code snipped]

Quote:

> #$salt = $chars[rand($#chars)] . $chars[rand($#chars)];    # Line 7

Anno


Tue, 04 Nov 2003 17:44:02 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Why no regex char class for punc chars???

2. Appending char to strings by char

3. Replacing special chars with special chars

4. Q: using a c-lib with char** and even char***

5. s/Hex/Char/ ? s/Char/Hex/

6. reading char by char in a string

7. Replacing multiple occurences of newline chars with a single newline char

8. Match any char EXCEPT [char]

9. Char-by-char client/server with echo option!?

10. Char position of 1st non-word char in a string

11. Char-by-char in internet server?

12. How can I match a char instead of any number of chars?

 

 
Powered by phpBB® Forum Software