|
User since: |
Apr 29, 2003 at 07:28 UTC
(22 years ago) |
Last here: |
Mar 06, 2024 at 09:01 UTC
(46 weeks ago) |
Experience: |
7292
|
Level: | Parson (16) |
Writeups: |
952
|
Location: | (near) Aix-La-Chappell, Germany |
User's localtime: |
Jan 20, 2025 at 06:59 CET
|
Scratchpad: |
View
|
For this user: | Search nodes |
|
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.
Useful Character Set information: [https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/]
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); }
sub man { pod2usage(-verbose=>2); }
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:
- mkdir -p
use File::Basename;
mkdir_p("some/long/path");
sub mkdir_p {
return ((-d $_[0]) or (mkdir_p(dirname $_[0]) and mkdir $_[0], 075
+5));
}
- 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;
}
bit-vec for more than 31 bits.
my $vec = [];
sub setBit {
my($vec, $offset, $val)= @_;
my $index= $offset >> 31;
my $subset= $offset & 0x7fffffff;
$vec->[$index]||='';
vec($vec->[$index], $subset, 1)= ($val & 1);
}
sub getBit {
my($vec, $offset)= @_;
my $index= $offset >> 31;
my $subset= $offset & 0x7fffffff;
$vec->[$index]||='';
return vec($vec->[$index], $subset, 1);
}
my old signatures
- $\=~s;s*.*;q^|D9JYJ^^qq^\//\\\///^;ex;print
- s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
|