Half a life time ago, moritz++ asked me to blog about how we use Perl 6 in production after I mentioned that we went a very traditional way to introduce a Perl in a company. A Perl because almost all our production code is written in Perl 5. So where does Perl 6 enter the picture?
A little over a year ago we turned our single image servers into a kvm based virtualization cluster with one VM per service for the security benefit of well separated systems. The systems running in those VMs are configured by puppet but we also wanted the VMs themselves to be automatically created by puppet. Our sysadmins started writing bash scripts for that job but suffice to say, my programmer eyes could not stand the code. So I showed my admins some Perl 6 and it soon became apparent how well suited the language is for writing sysadminy scripts. A great example is my personal favourite feature: MAIN subs.
sub MAIN(Str :$vm-name!, Int :$ram!, Str :$disk-space!, Int :$vcpus!, Bool :$public)
With just this line we not only get automatic a fully automated usage text:
Usage:
create_vm.pl6 --vm-name=<Str> --ram=<Int> --disk-space=<Str> --vcpus=<Int> [--public]
but also argument parsing and validation. Did you notice that it expects just a number for RAM while disk space accepts a string? No need to guess which argument expects a unit suffix and which doesn't. Of course, tasks processing our DHCP configuration to find the highest unused IP address in the server range have always been home territory for Perl and Perl 6 is no exception.
Whenever we need to host a new service, a Perl 6 script on the admin's machine creates the configuration and puppet will run another Perl 6 script to actually provision storage space, create the drbd device and finally copy our master image and prepare it for its first run. So it's fair to say that Perl 6 is an essential part at the very heart of our operations.
Just as Perl 5 set out to ease the life of system administrators, Perl 6 is your friend when you need it. It not only helps with technical challenges of automation, but also with the social side by giving your users help, preventing mistakes and by helping to keep your scripts maintainable.