Warning: Undefined array key "rss_show_deleted" in /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php on line 86
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 53
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 54
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 55
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 56
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/inc/httputils.php on line 32
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/inc/httputils.php on line 33 wi12.unix7.org - perl
https://w12.unix7.org/
Wed, 05 Aug 2026 03:50:26 +0000FeedCreator 1.8https://w12.unix7.org/_media/wiki/dokuwiki.svgwi12.unix7.org
https://w12.unix7.org/
https://w12.unix7.org/perl/auth3
perl app
#!/usr/bin/env perl
my $hostname = 'www.gnu.org';
use Digest::MD5 qw(md5_hex);
sub do_client_hash {
my $hostname = shift;
my $salt = '1234567890';
my $hash = md5_hex($hostname . $salt);
$hash;
}
my $client_hash = do_client_hash($hostname);
sub do_provider_hash {
my $client_hash = shift;
my $time = shift;
my $salt = '1234567890';
$time . ':' . md5_hex($client_hash . $time . $salt);
}
my $last = '1516895592';
my $key = do_provider_hash($client_hash…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Service check/validation tool
https://w12.unix7.org/perl/checker
perl app
Service check/validation tool
Rapid-made tool for IT company staff.
use strict;
use Net::Ping;
use Socket;
use Net::Traceroute::PurePerl;
use DBI;
use DBD::Pg;
use Data::Dumper;
use LWP::UserAgent;
use utf8;
binmode(STDOUT,':utf8');
sub logwrite($) {
my ($str) = @_;
my $log = "/checker-log.txt";
open(my $fh, ">>", $log);
my $str = shift;
print $str;
print $fh $str;
close $fh;
}
sub host($) {
my ($host) = @_;
my @addresses = gethostbyname($hos…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Simple configuration file parser
https://w12.unix7.org/perl/confread
perl app
Simple configuration file parser
#!/usr/bin/env perl
package Config;
use strict;
use warnings;
sub new {
my ($class, $file) = @_;
my $self = {
file => $file
};
bless $self, $class;
$self;
}
sub file {
my ($self, $name) = @_;
return $self->{'file'} unless $name;
$self->{'file'} = $name;
$self;
}
sub read {
my $self = shift;
return undef unless -r $self->file;
open my $fh, '<', $self->file;
my %res;
while (my $line …anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Planner Who Remembers
https://w12.unix7.org/perl/cron-w-rem
perl app
Planner Who Remembers
A single-threaded schedule executor who does not miss scheduled task due to employment.
I wrote it for DBdumper, Network distributed dump/restore system
#!/usr/bin/env perl
package aCron;
use strict;
use warnings;
use POSIX qw(strftime);
use Mojo::Util qw(dumper);
sub new {
my $class = shift;
my %quantums;
my %minutes;
my $self = {
quantums => \%quantums,
minutes => \%minutes,
quantum_wide => 2,
minute_wide =>…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000PgSQL DB list maker
https://w12.unix7.org/perl/db-list-maker
perl app
PgSQL DB list maker
#!/usr/local/bin/perl
#
# $Id: db-list.pl,v 1.1 2017/06/26 12:45:18 root Exp $
#
package DBH;
use utf8;
use DBI;
use Data::Dumper;
sub new {
my ($class, $dbhost, $username, $password) = @_;
my $self = {
dsn => "dbi:Pg:dbname=postgres;host=$dbhost",
username => $username,
password => $password
};
bless $self, $class;
return $self;
}
sub dsn { return shift->{dsn}; }
sub username { return shift->{username}; }
sub passw…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Perl disk usage subroutine
https://w12.unix7.org/perl/du
perl app
Perl disk usage subroutine
“Yet another unix du” =)
I wrote this for specific mailbox size calculation.
#!/usr/bin/env perl
use strict;
use warnings;
use File::stat;
sub du {
my ($subj, $maxdeep, $deep) = @_;
$maxdeep ||= 10;
$deep ||= 0;
my $stat = stat($subj);
return int($stat->size/1024) if -f $subj;
$deep += 1;
return 0 if $deep > $maxdeep;
opendir(my $dir, $subj) or return 0;
my $res ||= 0;
foreach my $rec (readdir $dir) {
…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Exim rules
https://w12.unix7.org/perl/exim-rules
perl app
Exim rules
MAIL FROM, acl_check_mail
Context Local sender Outside sender Auth yes accept deny Auth no deny accept
Local sender = Sender from local domain
Outside sender = Sender from no-local domain
RCPT TO, acl_check_rcpt
Contextanonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000SOAP to JSON RPC convertor/ JSON RPC application
https://w12.unix7.org/perl/jrpcd
perl app
SOAP to JSON RPC convertor/ JSON RPC application
This small application was planned to use for authentication service about 1200 users on 8 application servers.
I refused this decision because this work will not be paid to me :-\ =)
Nevertheless it is good working even in this beta stage. To add functionally, you only need to add your code/methods to aRPC object (see main code below).anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Simple JSON RPC on Perl
https://w12.unix7.org/perl/json-rpc
perl app
Simple JSON RPC on Perl
Now w/o error handling.
You can use any transport. In the example I use memory.
#!/usr/bin/env perl
# --- Dispatcher, Server side
package aRPCD;
use strict;
use warnings;
use Scalar::Util qw(reftype);
use Mojo::Util qw(dumper);
use Mojo::JSON qw(encode_json decode_json);
sub new {
my $class = shift;
my $self = {
func => undef
};
bless $self, $class;
return $self;
}
sub add {
my ($self, $key, $val) = @_;
my %ret;
$…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Maacom, simple web mail account manager
https://w12.unix7.org/perl/maacom
perl app
Maacom, simple web mail account manager
Mail account manager, or easy “Maacom” =)
I wrote this application for using into small-middle corporation.
I wanted to write a simple classic object-oriented web application, that can be used as a training application.anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000out
https://w12.unix7.org/perl/migr-pg-db
perl app
#!/usr/bin/env perl
use strict;
use warnings;
use Net::SSH2;
my $db = $ARGV[0];
do { print 'you must specificity database\n'; exit; } unless $db;
sub system_comm {
my $comm = shift;
return undef unless $comm;
open HR, "$comm |" or return undef;
my $out;
while (my $str = <HR>) {
$out .= $str;
};
return $out;
}
my $host = "pgdbxxxx.xxxxx.com";
my $user = 'xxxx';
my $password = 'xxxxxxx';
my $ssh2 = Net::SSH2->new;
$ssh2->connect($host)
or…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000MIME::Lite sample
https://w12.unix7.org/perl/mime-lite-sample
perl app
MIME::Lite sample
#!/usr/bin/env perl
use strict;
use MIME::Lite;
use MIME::Base64 qw(encode_base64);
use Encode qw(decode encode);
my $from = 'some@sender.org';
my $to = 'some@bare.com';
my $subject = 'Hello Привет';
$msg = MIME::Lite->new(
From => $from,
To => $to,
Subject => "=?UTF-8?B?" . encode_base64($subject, "") . "?=",
Type => 'multipart/mixed',
);
$msg->attach(
Type => 'text/plain; charset=UTF-8',
Data …anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Nano framework: JSON RPC server
https://w12.unix7.org/perl/nano-jrpc
perl app
Nano framework: JSON RPC server
I wrote it for small embedded automation. It use only stable and wide shared HTTP::Daemon and threads.
The example I publish without demonize code, config reader and other optional code for easy view.
Full small work application you can look thereanonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Perl OOP in pure C
https://w12.unix7.org/perl/perl-and-c-oop
perl app purec c
Perl OOP in pure C
use 5.008009;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'GPS',
VERSION_FROM => 'GPS.pm',
PREREQ_PM => {},
ABSTRACT_FROM => 'GPS.pm',
AUTHOR => 'Ziggi Stardust',
LIBS => [''],
DEFINE => '',
INC => '',
# OBJECT => '$(O_FILES)',
);anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Minimal perl cron-like scheduler
https://w12.unix7.org/perl/perlcron
perl app
Minimal perl cron-like scheduler
I used seconds for a better view. And to shorten a test time. =)
#!/usr/bin/env perl
use POSIX qw(tzset tzname strftime);
use Mojo::Util qw(dumper);
$ENV{TZ} = 'Europe/Moscow';
tzset;
sub expand {
my ($def, $limit, $start) = @_;
$limit = 100 unless defined $limit;
$start = 1 unless defined $start;
my @list = split ',', $def;
my @out;
my %n;
foreach my $sub (@list) {
if (my ($num) = $sub =~ m/^(\d+)$/ ) {
…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Tools for dumping all Postgresql databases
https://w12.unix7.org/perl/pg-dump-all
perl app
Tools for dumping all Postgresql databases
#!/usr/bin/env perl
package PGu;
use Data::Dumper;
use DBI;
use strict;
sub new {
my ($class, $pghost, $username, $password) = @_;
my $self = {
pghost => $pghost,
dsn => "dbi:Pg:dbname=postgres;host=$pghost",
username => $username,
password => $password,
};
bless $self, $class;
return $self;
}
sub dsn { return shift->{dsn}; }
sub username { return shift->{username}; }
sub password { re…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Dump all postgresql databases into separate sqlz file
https://w12.unix7.org/perl/pgdump-all
perl app
Dump all postgresql databases into separate sqlz file
#!/usr/bin/env perl
package PGu;
use Data::Dumper;
use DBI;
use strict;
sub new {
my ($class, $pghost, $username, $password) = @_;
my $self = {
pghost => $pghost,
dsn => "dbi:Pg:dbname=postgres;host=$pghost",
username => $username,
password => $password,
};
bless $self, $class;
return $self;
}
# read only accessors
sub dsn { return shift->{dsn}; }
sub username { return shif…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000
https://w12.unix7.org/perl/pool-machine
perl app
#!/usr/bin/env perl
package Pool;
use strict;
use warnings;
sub new {
my $class = shift;
my @pool;
my $self = {
pool => \@pool,
pos => 0
};
bless $self, $class;
return $self;
}
sub pool {
my ($self, $pool) = @_;
return $self->{pool} unless $pool;
$self->{pool} = $pool;
}
sub pos {
my ($self, $pos) = @_;
return $self->{pos} unless $pos;
return undef if $pos > ($self->count + 1);
$self->{pos} = $pos;
}
sub add {
…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Perl Mojo promises
https://w12.unix7.org/perl/promises-sample
perl app
Perl Mojo promises
#!/usr/bin/env perl
use v5.10;
use Mojo::Promise;
use Mojo::UserAgent;
# Wrap continuation-passing style APIs with promises
my $ua = Mojo::UserAgent->new;
sub get {
my $promise = Mojo::Promise->new;
$ua->get(@_ => sub {
my ($ua, $tx) = @_;
my $err = $tx->error;
$promise->resolve($tx) if !$err || $err->{code};
$promise->reject($err->{message});
});
…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000Squid account and quota manager
https://w12.unix7.org/perl/sqm
perl app
Squid account and quota manager
Or SQM for short.
I made it application from Maacom, with some specific logiс changes (access log scanner, password exporter, etc).
The application include sqm-helper, autentification helpler for Squid.
Used time for programming: total about 8-9 hours, too many time was checking in real work.anonymous@undisclosed.example.com (Anonymous)Sat, 05 Feb 2022 08:21:42 +0000OpenVPN account manager
https://w12.unix7.org/perl/vam
perl app
OpenVPN account manager
Or VAM for short.
I made it application based on Squid account and quota manager,
which I made based on Maacom, simple web mail account manager,
in the House That Jack Built =)
Time measure: 2.5 hours of first re-programming from copy of Squid account and quota manager
The application include vam-helper, autentification helpler for OpenVPN.anonymous@undisclosed.example.com (Anonymous)Sat, 05 Feb 2022 08:21:42 +0000