Next | Program Repair Shop | 50 |
Subject: why does this not work? Message-Id: <8l1r5c$n76$1@news-int.gatech.edu>
($current_month, $current_day, $current_year) = split(/-/, `date "+%m-%d-%Y"`); $current_year=chomp $current_year;
Even if it does work, it's bizarre and expensive
`date...` must open a pipe
fork a new process
execute the shell
which forks a new process
which executes the date command
After it's all over, we have to do a split
Shell calls can cause security problems in some contexts (example coming up)
Better:
($current_month, $current_day, $current_year) = (localtime)[4,3,5];
Next | Copyright © 2006 M. J. Dominus |