Hi All,
Can anybody tell me why is there a "0" in my output of $date_today ?
#!/usr/local/bin/perl
$date_today = system "date '+%y%m%d'";
print "$date_today\n";
Output:
$ perl test4
080908
0
Hi All,
Can anybody tell me why is there a "0" in my output of $date_today ?
#!/usr/local/bin/perl
$date_today = system "date '+%y%m%d'";
print "$date_today\n";
Output:
$ perl test4
080908
0
Hi,
The value of $date_today is zero (the return value of system if successful, 0).
The output You see is first the result of the system date command, and then the value of $date_today.
Maybe You wanted something like
$date_today = `date '+%y%m%d'`;
/Lakris
Hi Lakris,
Thanks a million!!
That's what i wanted!!
Here's another example, a bit aside from your test, you can work / play with :
sub get_timestamp {
@months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
@weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
$year = 1900 + $yearOffset;
$theTime = "$hour:$minute:$second|$weekDays[$dayOfWeek].$months[$month].$dayOfMonth.$year";
return $theTime;
}
I think I found it somewhere in the net, then I modified per my needs. The above subroutine call will return something like