I forgot to change the line my $h = hdatec::new_Hdate(); to my $h = new hdate::Hdate();
On Thu, Apr 15, 2010 at 6:34 PM, kobi zamir <kobi.za...@gmail.com> wrote: > Ohh.... Perl is an ugly language ... > > Here is the perl code with shlomi's sugestions, it works just the same. > > #------------------------------------------ > use strict; > use warnings; > use hdate; > > my $h = hdatec::new_Hdate(); > > $h->set_gdate(1,1,2010); > > my $julian = $h->get_julian(); > > for(my $i = 0; $i < 365; $i++) { > $h->set_jd($julian + $i); > > my $day = $h->get_gday(); > my $month = $h->get_gmonth(); > my $holyday = $h->get_holyday_string(1); > > if ($holyday) { > print "$day/$month $holyday\n"; > } > } > #------------------------------------------ > > On Thu, Apr 15, 2010 at 10:54 AM, Shlomi Fish <shlo...@iglu.org.il> wrote: >> Hi Kobi, >> >> some comments on your Perl code: >> >> On Thursday 15 Apr 2010 07:22:31 kobi zamir wrote: >>> > 3. Is there a way to semi automatically create the non regular dates, >>> > such as the postponed date of the holocaust day? Is there a known >>> > authoritative sites to pick these dates from? >>> >>> there are some fully automated ways :-) : >>> I. the command line hdate: >>> hdate -H 2010 >>> will print all the holidays for the year 2010 >>> >>> II. a python/perl script using libhdate will generate a list of holidays: >>> an example of such a python script is attached in earlier post in this >>> discussion. here is a perl example: >>> >>> # apt-get install libhdate-perl >>> #------------------------------------------- >>> >> >> Always add "use strict;" and "use warnings;" at the beginning of the file, >> after the shabang. Then fix all the errors that they report. >> >>> use hdate; >>> >> >> I realise it's probably too late to change it, but Perl module names should >> start with a capital letter - not with a lowercase ones. Modules that start >> with a lowercase letters are pragmas. >> >>> $h = hdatec::new_Hdate(); >>> >> >> Why does "use hdate" import the "hdatec::" namespace? This is inconsistent. >> >>> hdatec::Hdate_set_gdate($h,1,1,2010); >>> >> >> This would better be written as: >> >> {{{ >> $h->set_gdate(1,1,2010); >> }}} >> >> It won't work in this case, but could be food for thought for a future >> release. >> >>> $julian = hdatec::Hdate_get_julian($h); >>> >>> for($i = 0; $i < 365; $i++) { >>> hdatec::Hdate_set_jd($h, $julian + $i); >>> >>> $day = hdatec::Hdate_get_gday($h); >>> $month = hdatec::Hdate_get_gmonth($h); >>> $holyday = hdatec::Hdate_get_holyday_string($h, 1); >>> >>> if ($holyday) { >> >> English nit: it's "holiday" - not "holyday". >> >>> print $day . "/" . $month . " " . $holyday . "\n"; >> >> This is better done using interpolation: >> >> [code] >> print "$day/$month $holiday\n"; >> [/code] >> >> In the general case one should be careful not to introduce code/markup >> injections: >> >> http://community.livejournal.com/shlomif_tech/35301.html >> >> Regards, >> >> Shlomi Fish >> >> -- >> ----------------------------------------------------------------- >> Shlomi Fish http://www.shlomifish.org/ >> Why I Love Perl - http://shlom.in/joy-of-perl >> >> Deletionists delete Wikipedia articles that they consider lame. >> Chuck Norris deletes deletionists whom he considers lame. >> >> Please reply to list if it's a mailing list post - http://shlom.in/reply . >> > _______________________________________________ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il