Skip to content

Instantly share code, notes, and snippets.

@jluis
Created November 7, 2014 10:46
Show Gist options
  • Save jluis/53e6358b50f0d3175915 to your computer and use it in GitHub Desktop.
Save jluis/53e6358b50f0d3175915 to your computer and use it in GitHub Desktop.
Barcelona Perl Workshop 2014 Idcvs generator
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
use utf8;
binmode(STDOUT, ":utf8");
binmode(STDIN,":utf8");
say STDERR <<'usage';
idlist
giving an ACT users CVS file on STDIN generates a CSV file on STDOUT
and a QR png files on the current directory directing to the user page
on the workshop web that is used by Scribus to generate the final ids
usage
my @sal = qw(. Mr Mrs . Dr);
use Text::CSV;
use Image::PNG::QRCode 'qrpng';
my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attribute.
or die "Cannot use CSV: ".Text::CSV->error_diag ();
my $fh = *STDIN{IO};
$csv->getline($fh) ;#omit headers
while ( my $row = $csv->getline($fh) ) {
next unless $$row[11] or $$row[12]; #Talk or Payment
my $org = $$row[13]?'*':'';# Mark organizers
my $nick = $$row[6]?$$row[6]:"$$row[4] $$row[5]";#nick or name
my $name = $$row[7]?'':$$row[6]?"$$row[4] $$row[5]":'';# show the name when nick and not anonymous
say "$$row[0],$nick,$name,$org,$$row[10]";#id,..,Perl Mongers group
qrpng(out=>"$$row[0].png",scale=>10,text=>"http://workshop.barcelona.pm/barcelona2014/user/$$row[0]");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment