Category: perl

  • Using Perl to access PostgreSQL under Windows

    This appears by a non-intuitive problem for people. Below I assume that you are using some version of ActivePerl for Windows (5.8 or 5.10). First of all: Under no circumstances (ok, I rephrase: only under extreme circumstances) should you use DBD::PgPP. It is old, not very performant (given that its implemented in Pure Perl) and…

  • Calling variable functions in Perl

    What I’m trying to say with this title is the following: # … lets say we have a value $foo …. # … and we want to call method_1 method_2 … method_N on it foreach my $method_name (1..N) { $method_name = “method_$method_name”; my $func = *$method_name; my $result = &$func($foo); # … } The trick…

  • Sending authenticated mail with Net::SMTP

    As I’ve said earlier, one thing about open source is that you can fix fairly easily. In Perl this is especially easy, since it is turtles all the way down – many of the libraries are written in pure Perl, meaning that you can step through them with the Perl debugger. This helped me recently…

  • Breaking into the debugger programatically with Perl

    In some situations you might wish to programatically stop the execution of a script if a debugger is attached. Some use-case scenarios: You are debugging an area of the code which gets frequently executed (in a loop for example), but you are only interested to see its status under certain conditions You have a central…

  • Locking a script to a given user with Perl

    From a security point of view it is useful if you lock sensitive scripts (for example things which download untrusted data from the Internet) to run with a low privileged user. However it is also a good idea to make sure programatically that they are run only with the given user. One possible solution (which…

  • Get the IP of the local computer from Perl

    Caveat: this is only documented on Windows and may or may not work on other OSs (it doesn’t work on Ubuntu 8.04). Also, if the computer has multiple IP addresses (like a LAN, WLAN and a VLAN IP), there is no telling which IP this will return. Just a little snippet of code: print join(‘.’,…

  • Mixed links

    First of a nifty tool for all of you (us?) people using RDP: Terminal Server Ping Tool. What’s even better, it’s written in Delphi and the full source code is available. Opera 9.5 is out, making problems with older versions obsolete. At the same time, via the the Think Vitamin website, Opera Dragonfly. This seems…

  • Defense in depth for programming

    Two things you should always do when developing in Perl is to use strict and use warnings (with the caveat that warnings should be disabled in production systems or redirected to a log file). However recently I was reminded that nothing is 100% (and this isn’t a compiled-vs-interpreted issue, because there are many errors compilers…

  • Two simple things you can do for Perl right now!

    Go write a page for the Perl 5 Wiki and help it reach 1000 pages Rate a CPAN module

  • Installing Perl 5.10 on Ubuntu

    So I upgraded to Ubuntu 8.04 and I’m not very impressed unfortunately. I got Compiz working, thanks to Compiz-Check (it works only at lower resolutions, so I switched it off, however it’s nice to have the option) and also Monodevelop 1.0, however the installed Firefox is slightly outdated (Beta 5 rather than RC1) and sound…