 |
| User since: |
Apr 29, 2003 at 07:28 UTC
|
| Last here: |
May 24, 2013 at 20:41 UTC
(22 minutes ago) |
| Experience: |
5519
|
| Level: |
Vicar (15)
|
| Writeups: |
757
|
| Location: | (near) Aix-La-Chappell, Germany |
| User's localtime: |
May 24, 2013 at 23:03 CEST
|
| Scratchpad: |
View
|
|
The image was created using South Park Studio and Gimp.
I was introduced to the monastry by physi. He was my boss in a project.
I picked my name from Robert Asprin's books about M.Y.T.H. Inc. which I really love.
perlmonk nodes I often use:
My perl skeleton
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long qw(:config no_ignore_case);
use Pod::Usage;
my ( # options
$verbose,
$debug,
$file,
@columns,
);
$file= 'default.txt';
help() unless GetOptions(
'v' => \$verbose,
'verbose!' => \$verbose,
'debug+' => \$debug,
'file=s' => \$file,
'c|column=i' => \@columns,
'h|help' => \&help,
'm|man' => \&man,
);
sub help { pod2usage(-verbose=>1); exit; }
sub man { pod2usage(-verbose=>2); exit; }
print "OKAY\n";
# Program goes here...
=head1 NAME
Getopt::Long / Pod::Usage skeleton
=head1 SYNOPSIS
skeleton.pl [options]
=head1 DESCRIPTION
This is a skeleton I use when creating a new perl script
=head1 OPTIONS
=over 4
=item B<-v>
verbose outoput
=item B<-d>
=item B<-debug>
debug mode
=item B<-file> F<filename>
specify the file to work with
=back
=head1 BUGS
none yet
=head1 TODO
much
=cut
Things I might need (again) in the future:
- IP v4 address manipulations
#!/usr/bin/perl
use strict;
use warnings;
use Socket;
my $ifconfig='/usr/sbin/ifconfig';
# run ifconfig -a
open my $if, '-|', "$ifconfig -a" or die "Couldn't run $ifconfig: $!\n
+";
while (<$if>) {
# find a line with "broadcast" in it
# on Solaris this contains all the information I need
next unless /inet\s+(.*?)\s+netmask\s+(.*?)\s+broadcast\s+(.*?
+)\s*$/;
# keep ip address as it is (a dotted string)
my $iaddr= $1;
# convert the netmask to a "long"
my $netmsk= hex "0x$2";
# dito for the broadcast
my $brdcst= unpack 'N', inet_aton $3;
# How many bits does the netmask have?
my $bits= 31-int(log(0xffffffff ^ $netmsk)/log(2));
# Convert the netmask to a "slashed" IP
my $network= inet_ntoa(pack "N", ($brdcst & $netmsk)) . "/" .
+$bits;
# show all info found
print "$iaddr\t$network\n";
}
close $if;
- Reverse DNS Lookup
use Socket;
my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyaddr(inet_aton
+("74.125.79.94"));
print $name,$/;
- Building perl on Solaris with gcc
- Building perl DBI (on Solaris) with gcc
perl Makefile.PL CC=gcc LD=gcc CCCDLFLAGS=-fPIC OPTIMIZE=-O3
This is not necessary if you build your own perl as above in which case the normal process will work.
- Building DBD::mySQL ...
make sure .../mysql/bin is in your path
- CSV splitting without modules
sub csvsplit {
my (@result);
for ($_[0]) {
s/[\015\012]+$//;
while (s/^"((?:[^"\\]|\\.)*)"// || s/^'((?:[^'\\]|\\.)*)'// ||
+ s/^([^,]*)//) {
push(@result, $1);
last unless s/^,//;
}
}
return @result;
}
my old signatures
- $\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print
- s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
|