Posts

Showing posts from December, 2011

List all installed and available Perl modules

Code below provides list of modules which perl interpreter can find in runtime. Code#!/usr/bin/perl # # Author: Tomasz Gaweda # Date: 2011.12.23 17:00 # Purpose: Print all modules installed # in perl distribution # # Usage: perl showmodules.pl use strict; use warnings; use File::Find; my @modules; my $IgnorePatt = join("|",@INC) ;#$IgnorePatt =~ s/\|\.// ; find( sub { my $f = $File::Find::name; if ( $f =~ s/^(${IgnorePatt})\/(.*?)\.pm$/$2/ ) { $f =~ s/[\/\\]/::/g; push @modules, $f; } } , grep { -d } @INC ); print "There are [".scalar(@modules)."] modules that perl can locate on runtime...\n"; print "Printing List in Minute\n" ; sleep 3; print join("\n", sort{ lc $a cmp lc $b} @modules)."\n";Sample outputThere are [2346] modules that perl can locate on runtime... Printing List in Minute AcidRip::acidrip AcidRip::interface AcidRip::messages AcidRip::signals AE Algorithm::C3 Algorithm::Diff …

Encoding files "on the fly" with Blowfish using Perl

Some time ago friend of mine asked me if I could write him an CGI script which encodes his backup file and allows to download it using HTTP protocol.He is using some kind of VPS so my CGI app had some limitations:file must be encoded "on the fly" to save disk space (no temporary files)encoding should be memmory efficient - because VPS hasn't got very much RAM and backup files are quite largeencoding should be fast - so the best solution would be using XS moduleAfter some research I've created this two scripts: Warning: Scripts depends on external Perl modules which are available at CPAN and in Debian repository. apt-get install libcrypt-cbc-perl libcrypt-blowfish-perlBlowfish CGI encoding using Perl#!/usr/bin/perl use strict; use warnings; use CGI; use HTML::Entities; use Crypt::CBC; use File::Spec; my $as_cgi = 1; # if run from apachce set to 1 if CLI 0 my $key = "ala_ma_kota.123"; my $fName = './large_file.bin'; my $chunkSize = 1024; my $ou…