| [ CnUnix ] in KIDS 글 쓴 이(By): shanx (rlatio) 날 짜 (Date): 2002년 10월 23일 수요일 오후 12시 27분 49초 제 목(Title): Re: rand(): Perl에서 요새 Perl에선 srand 매뉴얼하게 호출할 필요가 없지 않나요? rand에서 알아서 srand를 써서 초기화 시켜줍니다. 그것도 시스템의 random 디바이스 파일 같은 것을 이용해서 비교적 좋은 램덤 초기값을 설정해줍니다. 굳이 srand를 쓰는 이유가 이젠 같은 랜덤 시퀀스를 얻기 위해서 쓰는 것으로 전락(?)되었을 정도죠. % perldoc perlfunc 에서 srand 부분을 읽어보세요 srand Sets the random number seed for the `rand' opera- tor. If EXPR is omitted, uses a semi-random value supplied by the kernel (if it supports the /dev/urandom device) or based on the current time and process ID, among other things. ....... In fact, it's usually not necessary to call `srand' at all, because if it is not called explicitly, it is called implicitly at the first use of the `rand' operator. ...... Do not call `srand' multiple times in your program unless you know exactly what you're doing and why you're doing it. |