Section for Week 5, Tuesday, 2/9/99 1. Hand back exams, go over solutions & grading. Midterm #1 histogram: 1 6 2 03344556789999 3 0122233445666678888899 4 00111112222233344445667779 2. Date & Time functions: time() -- will return the number of seconds since 1/1/1970 localtime(time) -- will take the return value of time() and convert it into a nine element list: # 0 1 2 3 4 5 6 7 8 seconds,minutes,hours,dayInMonth,Month (starting at 0), year, day in week, day in year, is it Daylight savings? ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); In scalar context will return a string like: Tue Feb 9 10:27:55 1999 So: the code $x= localtime(time); print $x. "\n".join(':',localtime(time))."\n"; Produces: Tue Feb 9 10:28:48 1999 48:28:10:9:1:99:2:39:0 gmtime() will do same, but for Greenwich Mean Time. 3. $0 == name of your perl script: $#ARGV==1 || die "Usage: $0 arg1 arg2\n"; 4. hex/decimal conversion: If you have a string $str containing a hex number (pattern matches /^x?[0-9a-f]*$/i) then hex($str) will return the decimal value of the contents of $str. Sim'ly oct($str) will return the decimal value of the contents of $str, assuming it is a well-formed octal number (/^[0-7]*$/).