Category: perl

  • Connecting to the MtGox market data feed using Perl

    For a recent project I needed some realistic market data for an electronic exchange. Seeing how MtGox provides free and open access to theirs (thank you!) I chose them. However none of the examples floating around the internet seemed to work, so I whipped one up using Net::Async::WebSocket::Client. Enjoy: use IO::Async::Loop; use Net::Async::WebSocket::Client; my $client…

  • Lightning talk at Cluj.PM

    The slides from my Cluj.PM lightning talk: It was a stressful (but fun!) experience. Thanks to the organizers!

  • Non-buffered processor in Perl

    Lets say that you have the following problem: you want to write a script which processes the output of a program and writes out the modified somewere, with as little buffering as possible. One concrete example (for which I needed the script) is log rotation: you want to save the output of a program (which…

  • Processing clipboard data in Perl

    The problem: lets say you have a program which generates data to the clipboard (or it is easier to get the data into the clipboard than into a file) and you want to process the data (create a summary for example). Perl to the rescue! Get the Clipboard module (if you use Linux, it is…

  • Sending an X-Face email with Perl+GMail

    In the latest Software Freedom Law Show Bradley mentioned the X-Face email header and challenged listeners to send them an email containing the X-Face header. So here is the small Perl script I’ve whipped together to send them an email trough GMail: use strict; use warnings; use Net::SMTP::TLS; my ($from, $password) = (‘…@gmail.com’, ‘MySuperSecretPassword’); my…

  • Solving mathematical puzzles with brute-force and Perl

    After talking a lot about optimizations and selecting the right algorithm, here is a little brute-force code. This particular one gives the answer to the following puzzle from Richard Wiseman’s Blog (one well worth following BTW): Can you make the number 24 with the number 5, 5, 5, and 1 (again, you cannot join the…

  • Unshortifying Cisco “Go” links

    Inspired by a post on the PacketLife.net blog – Cisco "Go" links reference in the wiki – I tried to mine the short links to come up with the “definitive” list, but after running it for a couple of days, it only managed to find 473 links, compared to the 4720 Google estimates it has…

  • Parsing pcap files with Perl

    Recently I was reading the blogpost on the BrekingPoint labs log about parsing pcap files with Perl and I immediately said to myself: it is impossible that there isn’t a module on CPAN, because Perl is great. Turns out I was right, there is Net::TcpDumpLog which can be combined with the NetPacket family of modules…

  • In praise of Regexp::Assemble

    …and of the Perl modules in general. I had the following problem: Given a list of 16 character alphanumeric IDs, find all the lines from a large-ish (~6GB) logfile which contain at least one of the IDs. The naive approach was to construct a big regular expression like W(QID1E|QID2E|QID3E…)W and match it against every line…

  • Carving out files with Perl

    I’ve had to use this trick a couple of times the last few years, so I decided that I might as well document it: If you have an image of a storage media (like an SD card or CD/DVD) which you can not mount (either because the filesystem is hosed – that’s a technical term…