Acessing function parameters in Perl

Perl functions don’t have parameters, their arguments are passed in an array @_. You can simulate parameters by assigning to a list, but you can also just apply the usual array operations to @_.

To put in another way, Perl automatically populates the special @_ variable each time you call a function. You can access it in multiple ways:

directly, by simply using @_ or individual elements within it as $_[0], $_[1], and so on
by assigning it to another array, as shown above
by assigning it to a list of scalars (or possibly a hash, or another array, or combinations thereof):

Note that in this form you need to put the array @others at the end, because if you put it in earlier, it’ll slurp up all of the elements of @_. In other words, this won’t work:

You can also use shift to pull values off of @_:

Note that shift will automatically work on @_ if you don’t supply it with an argument.

You can also use named arguments by using a hash or a hash reference. For example, if you called wut() like:

This would be a good way to introduce named parameters into your functions, so that you can add parameters later and you don’t have to worry about the order in which they’re passed.

How to Setup Unattended Upgrades on Debian Stretch

Debian is a volunteer project that has developed and maintained a GNU/Linux operating system for well over a decade. Since its launch, the Debian project has grown to comprise more than 1,000 members with official developer status, alongside many more volunteers and contributors. Today, Debian encompasses over 50,000 packages of free, open source applications and documentation. The popular distribution Ubuntu builds on the Debian architecture and infrastructure and collaborates widely with Debian developers, but there are important differences. Ubuntu has a distinctive user interface, a separate developer community (though many developers participate in both projects) and a different release process.

If you decide to use a Debian server for your project (good idea – it’s secure, robust and fast), then you should always have the latest security patches and updates, whether you’re asleep or not. This is actually pretty easy to do. Here’s how.

Continue reading

Using a local APT Repository for your Student VM

Advanced Package Tool, or APT, is a free software user interface that works with core libraries to handle the installation and removal of software on Debian, Ubuntu and other Linux distributions. APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, either from precompiled files or by compiling source code.

Continue reading

Send Email from a Virtual Server in DkIT

The Cloud Virtualisation Platform we have built at https://xoa.comp.dkit.ie is a fantastic resource, comparable to AWS, Digital Ocean etc but yet free and importantly, secure because it is inside the DkIT Firewall. However, this same security can prevent useful features most server can do easily, like sending email.

This tutorial details how to configure your virtual server in DkIT to send email via the Microsoft Outlook Mail Server (which is actually the other side of the firewall).

Continue reading