perldoc usage

Posted by root Wed, 09 Jan 2008 10:59:00 GMT

function manual:
perldoc -f grep
search the text in perlfaq:
perldoc -q grep
module content:
perldoc -m IO::Socket
module absolute filename:
perldoc -l IO::Socket
and of course:
perldoc perl

Posted in  | Tags  | no comments

Just_Another_Perl_Hacker.pm

Posted by root Wed, 09 Jan 2008 05:03:00 GMT

package Just_Another_Perl_Hacker; $$
perl -MJust_Another_Perl_Hacker -e 's|(?<=\w)_| |g && tr/:://d && print for keys %main::'

Posted in  | Tags  | no comments

Getting ip addresses from log file

Posted by root Tue, 08 Jan 2008 09:10:00 GMT

perl -ne

$_{$1}=1 if /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;eof&&{print join("\n", sort keys %_)}
access.log

Posted in  | Tags ,  | no comments

Fast ICMP scanner (Perl oneliner)

Posted by root Tue, 08 Jan 2008 08:05:00 GMT

[localhost]$

time perl -MNet::Ping -e '$p = Net::Ping->new();
@hosts = qw(
127.0.0.1 
172.16.0.1 
172.16.0.2 
172.16.0.5 
172.16.0.254);
#the significant detail
$p->{"timeout"} = 0.005; 
for (@hosts) { print "$_ is ".($p->ping($_) ? "up" : "down").$/ }'

127.0.0.1 is up
172.16.0.1 is up
172.16.0.2 is down
172.16.0.5 is up
172.16.0.254 is down

real 0m0.062s
user 0m0.040s
sys 0m0.000s

Posted in  | Tags ,  | no comments

nmap cleaner in Perl

Posted by root Sat, 29 Dec 2007 15:26:00 GMT

$”=” @ARGV”;/^\D+/||print for`nmap$”`

Posted in ,  | no comments

List Values and Arrays

Posted by root Fri, 30 Nov 2007 14:28:00 GMT

Perl

($a, $b) = (1, 2);
 @arr    = (1, 2);

Python
 a, b = 1, 2
 arr  = 1, 2;

Ruby
 a, b = 1, 2
 arr  = 1, 2
 arr  = 1,2, *[11,22] # the same as 
 arr  = [1,2, [11,22]].flatten
the ’*’ example was stolen from Ola Bini’s blog

Posted in , ,  | Tags  | no comments

Older posts: 1 2