use perl to get timestamp
[
2009/10/30 08:48 | by askwan ]
2009/10/30 08:48 | by askwan ]
in different context have different value
eg:
saclar context
print scalar (localtime);
then output :
Thu Oct 29 18:50:01 2009
but in list context ;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
$sec 0 ~ 59
$min 0 ~ 59
$hour 0 ~ 23
$mday 1~31
$mon 0 ~ 11
$year after 1900,it passed years
$wday 0 ~ 6
$yday 0 ~365
$isdst insignificant for me
can use this to get timestamp
output:
2009-10-29 19:2:40
have some defect ablove,use this
output:
2009-10-29 19:02:45
you can also use POSIX functions:
eg
output:
2009-10-29 11:10:44
2009-10-29 19:10:44
eg:
saclar context
print scalar (localtime);
then output :
Thu Oct 29 18:50:01 2009
but in list context ;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
$sec 0 ~ 59
$min 0 ~ 59
$hour 0 ~ 23
$mday 1~31
$mon 0 ~ 11
$year after 1900,it passed years
$wday 0 ~ 6
$yday 0 ~365
$isdst insignificant for me
can use this to get timestamp
output:
2009-10-29 19:2:40
have some defect ablove,use this
output:
2009-10-29 19:02:45
you can also use POSIX functions:
eg
output:
2009-10-29 11:10:44
2009-10-29 19:10:44
use DBD::Pg to connect PostgreSQL database
[
2009/10/20 10:01 | by askwan ]
2009/10/20 10:01 | by askwan ]
first, install DBI and DBD::Pg module
come next two example I have writen for testing:
example one:
example two:
output :
come next two example I have writen for testing:
example one:
example two:
output :
datname blks_read blks_hit
------------------------------------------------------------
template1 0 0
template0 0 0
postgres 136 5955
askwan 124 7396
use DBD::Oracle connect oracle database
[
2009/09/10 20:40 | by askwan ]
2009/09/10 20:40 | by askwan ]
the first way:
the second way:
----------END-----------
the second way:
----------END-----------
simple way to parse apache log with perl to find top 10 clients
[
2009/09/04 15:03 | by askwan ]
2009/09/04 15:03 | by askwan ]
usage and output:
./parse_apache.pl [APACHE LOGFILE]
# perl parse_apache.pl access_askwan_com_logClient IPs Num Of Visits
192.168.11.8 1794924
192.168.11.60 80887
192.168.11.9 34403
192.168.11.50 18026
192.168.11.196 8379
192.168.11.201 1353
192.168.11.155 1041
192.168.21.156 449
192.168.21.161 163
192.168.12.2 84
-------------end--------------



