DEV Community

Lance Wicks
Lance Wicks

Posted on • Originally published at lancewicks.com on

Skipping a @perlwchallenge week, to do some #judo coding in #perl

This week, I tried to do week 75 and it just did not click. 🙁

That said, I did do some Perl coding for someone looking at doing some research into Judo. They reached out to me as a result of my http://rwjl.net site I think. On that page I ran a research project into an alternative ranking system for Olympic Judo using the ELO system used in Chess.

So the request via email, was a great surprise. It came from someone I deeply respect; so helping was a pleasure.

Perl, has always been a tool for automating tasks. It is the superglue for many tasks. So this week I used it to automate collating some competition results into a format that suited.

Specifically… the dreaded CSV format.

But being Perl, this was easy! just two lines and it was done.

So skipping to the CSV bit, I have an array of hashes. Each entry is the result of a contest in a international Judo competition. To write this data out to a .CSV file in perl looks like this:

use Text::CSV_XS 'csv';

...

my $err = csv( in => \@data, out => "summary_data.csv" );
Enter fullscreen mode Exit fullscreen mode

That’s basically it; copied directly from the POD documentation for the module (Text::CSV_XS).

This took the 167,000+ lines of data and produced a CSV with almost zero fuss. Perl rocks!

Top comments (0)