Sunday, November 10, 2013

Reformat the output of hebcal to be more useful


want to format the output from hebcal on combined lines like so




#!/usr/bin/perl -w
use strict;
use v5.10;
my @output=`hebcal -dsC 'new york'`;
my %hdata;
chomp @output;
foreach (@output) {
my ($date, $data)= split (/\s/,$_,2);
my ($month,$day,$year)=split(/\//,$date);
my $date=sprintf('%02s/%02s/%d',$month,$day,$year);

if (defined $hdata{$date}){
push( @{$hdata{$date}}, $data);
}
else {
$hdata{$date}=[$data];
}
}

foreach (sort (keys %hdata)) {

say "$_ @{$hdata{$_}}";
}