#!/usr/bin/perl -w ## ## Programmer: Craig Stuart Sapp ## Creation Date: Fri Jul 23 04:43:31 PDT 1999 ## Last Modified: Fri Jul 23 04:43:36 PDT 1999 ## Filename: /home/httpd/cgi-bin/randomtime ## Syntax: Perl 5 ## ## Description: A demonstration of (1) how to return variables ## from a subroutine, (2) how to get the hour of the ## day, (3) how to get a random number, and ## (4) how to concatenate two strings together ## to create a session ID from the hour and the ## random number. ## print getsessionname(), "\n"; sub getsessionname { my ($hour, $id); $hour = (localtime)[2]; if (length($hour) == 1) { $hour = "0" . $hour; } $id = int(rand()*900000+100000); return $hour . $id; }