Perl on Raspberry Pi

Citrus Perl and Raspberry Pi

New HiPi Distribution

The HiPi modules released with Citrus Perl for Raspberry Pi have been replaced with a stand alone distribution intended for installation in the standard system Perl.

I decided for several reasons that on the Raspberry Pi it is more appropriate to use the system Perl so directed my efforts towards a distribution that uses Module::Build to install all prerequisites using the standard apt-get and provide PAR::Dist based installs for Wx and Alien::wxWidgets.

Enabling I2C, SPI and 1 Wire

If you have some hardware with an I2C, SPI or 1 Wire interface connected to your Raspberry Pi you need to enable the kernel modules that drive these interfaces.

The Raspbian Wheezy images from onwards contain the necessary kernel modules but they are not enabled by default. You must edit a couple of configuration files and install the i2c-tools package first.

You need to remove the 'blacklist' entries from raspi-blacklist.conf.

sudo nano /etc/modprobe.d/raspi-blacklist.conf

You need to comment out the two blacklist entries as above. Save and exit from the editor (ctrl O and ctrl X).

Next you need to add the i2c-dev and 1 wire modules to /etc/modules.

sudo nano /etc/modules


Add the lines 'i2c-dev', 'w1-gpio' and 'w1-therm' as above. Save and exit from the editor (ctrl O and ctrl X ). Install the i2c-tools package.

sudo apt-get install i2c-tools

You should now reboot your Raspberry Pi

sudo shutdown -r now

Once rebooted you can detect i2c devices attached to your Raspberry Pi (if any).

sudo i2cdetect -y 1

If you have a Revision 1 board you will need to use 
         sudo i2cdetect -y 0

Citrus Perl on Raspberry



My current and future development is concentrating on a stand alone distribution of Perl modules, Perl and Raspberry Pi, for installation in the system Perl on Raspberry Pi.

As you might expect Perl is provided as part of the standard Raspbian Wheezy images. However, I always like to work with a separate installation of Perl. It means that I don't interfere or conflict with the system processes that rely on the system Perl and I can configure my Perl according to my own requirements.

I have supported a binary Perl distribution called Citrus Perl for some time. It provides wxPerl GUI tools along with pre-built modules to connect to common Open Source databases and is available for Windows, Linux on x86 / x86_64 and Mac OS X. 

I have produced a binary version of Citrus Perl for Raspbian Wheezy to provide a similar environment for the Raspberry Pi and have released it for download and installation.

Before downloading and installing Citrus Perl you need to install a few prerequisites. The standard Raspbian images use the gcc compiler version 4.6.3 by default. Perl compilation fails for ARM processors as used in the Raspberry Pi using this compiler. The later release gcc 4.7 is required. We can install gcc 4.7 on the Raspberry Pi. It can co-exist happily with the standard gcc 4.6.3.

If you have not updated your package system recently, you should do so first.

sudo apt-get update

You can then install compiler tools that will allow Citrus Perl to build modules as required from the CPAN.

sudo apt-get install make gcc-4.7 g++-4.7

The final prerequisites are the database client libraries if you intend to use DBD::Pg or DBD::mysql -

sudo apt-get install libmysqlclient18 libpq5

Citrus Perl installs from a tarball to a fixed location under /var/local. The installation path is /var/local/citrus so the tarball is simply the 'citrus' directory. You should download and extract Citrus Perl using 'sudo'.

cd /var/local

sudo wget

sudo tar xjf citrus-raspbian-20130201.tar.bz2

Installation is then complete. To use Citrus Perl you can run a script referencing the executable directly -


Or you can put the necessary directories on your path within a session so that the Citrus Perl executable becomes the default for that session - 

export PATH=/var/local/citrus/site/bin:


You can also make your scripts executable and use the first script line to identify the required command -

#!/var/local/citrus/bin/perl -w

For users of wxPerl you can run the WX::Demo application using :


or if you have exported the amended $PATH as above you can simply

For information, if you wish to build Perl from source rather than use a binary distribution, my configure script is here.

Setting Up My Pi

So, your Raspberry Pi has arrived and you are ready to set it up? There are plenty of tutorials available but I thought I would add mine here as I don't recall finding all the information I used in a single place.

The Raspberry Pi that I'll be setting up is a Model B Revision 2 board with 512 mb of memory. This version has its own ethernet port. It should work for any setup where you can get an ethernet connection on boot up of a fresh raspbian operating system.

My setup is a home network behind a router using a Windows machine as my main desktop. I want to setup the Raspberry Pi without using a dedicated keyboard, mouse and monitor. I'd like to plug it into the network, and connect to it using VNC. This is quite possible provided that you know the IP address that your router or other DHCP server has handed out to your Raspberry Pi.

If you connect to your router or DHCP service you can find out where you can see the list of connected machines. This is entirely dependent on your brand of router but should be fairly straightforward. It will be one of the main features of your router or DHCP server. The idea is that you look at the list of connected machines, then connect your Raspberry Pi to the network, then the new machine that appears on your router's list of connected machines is the Raspberry Pi. You just need to record the IP address which you can then use to connect to the Raspberry Pi from your desktop.

To set this up from a Windows desktop you will need:

Putty - this is an ssh client for Windows that you will use to make the initial connection to your Raspberry Pi. You can download and install this from the Putty Download Page. You want the installer for Windows which at the time of writing is called putty-0.62-installer.exe.

VNC Viewer - you need a VNC Viewer to connect to a graphical session on your RaspberryPi. There are several available but I used TightVNC from the TightVNC Download Page. You need the Windows installer for your type of system ( either 64 or 32 bit ).

Raspbian Image - You need an operating system to run on your Raspberry Pi. All the information on this site assumes you are using a Raspbian Wheezy image from the Raspberry Pi Download page. The steps in this blog entry have been tested against the and images. The image needs to be written to an SD card using Win32DiskImager. There are full instructions at the Raspberry Pi site on the Download Page.

You have Putty and TightVNC installed on your WIndows desktop and a Raspbian image on the SD card in your Raspberry Pi.

You need to connect to your router or DHCP server and bring up the list of connected machines.

Connect your Raspberry Pi to your network via the ethernet port and plug in the power. Once the Raspberry Pi has booted fully ( all indicator lights are on and have stopped flashing ) you can refresh your view of your router or DHCP service and identify which IP has been assigned to your Raspberry Pi. in my case it was

You are ready to connect using Putty. Start the Putty programme and enter the Raspberry Pi IP as the host address.

Click the open button and you should be presented with a terminal window. The default username is 'pi' and the default password is 'raspberry'.

Because this is the first boot of your image you should see a message suggesting you run sudo raspi-config. You should do so now.

sudo raspi-config

You need to select the option to expand_rootfs

Once this has completed you can 'finish'.

You now need to reboot the Raspberry Pi

sudo shutdown -r now

You can close the Putty window as the Raspberry Pi will disconnect anyway.

Once your Raspberry Pi has rebooted, you can start Putty again and connect as you did before.

After logging in, you will need to install the TightVNC server but before first usage you will need to update the package system.

sudo apt-get update

sudo apt-get install tightvncserver

Once installed, you need to run the tightvncserver once to set up your user configuration. Run the command


You will be asked for a password. You will use this when connecting from your Windows desktop, You will also be asked if you want to set a 'view only' password. You can answer 'no'.

The final thing you have to do is install a script in the /etc/init.d directory to run your VNC service at system boot. There is a prepared script here that you can install and configure using the following commands.

Change to the /etc/init.d directory

cd /etc/init.d

Download the script

sudo wget

Set the script permissions

sudo chmod 755 vncboot

Configure system initialisation for the script

sudo update-rc.d vncboot defaults

The boot script is now installed and configured. You now need to reboot your Raspberry Pi

sudo shutdown -r now

You can close the Putty window ( the Raspberry Pi will disconnect on reboot).

Once the Raspberry Pi has rebooted you should be able to run the TightVNC viewer programme on your Windows desktop and connect to the Raspberry Pi at the known IP address.


You will be prompted for your VNC password that was set up earlier and then you should have access to a graphical Raspberry Pi desktop.