Acme-Tools

 view release on metacpan or  search on metacpan

Tools.pm  view on Meta::CPAN


Example:

 ( $day, $month ) = easter( 2012 ); # $day == 8 and $month == 4

Example 2:

 my @e=map sprintf("%02d%02d", reverse(easter($_))), 1800..300000;
 print "First: ".min(@e)." Last: ".max(@e)."\n"; # First: 0322 Last: 0425

Note: The Spencer Jones formula differs Oudins used in C<easter()> in some years
before 1498. However, in that period the Julian calendar with a different formula was
used anyway. Countries introduced the current Gregorian calendar between 1583 and 1926.

=cut

sub easter { use integer;my$Y=shift;my$C=$Y/100;my$L=($C-$C/4-($C-($C-17)/25)/3+$Y%19*19+15)%30;
             (($L-=$L>28||($L>27?1-(21-$Y%19)/11:0))-=($Y+$Y/4+$L+2-$C+$C/4)%7)<4?($L+28,3):($L-3,4) }


=head2 time_fp

Tools.pm  view on Meta::CPAN


How many ways (permutations) can six people be placed around a table:

 One person:          one way
 Two persons:         two ways  (they can swap places)
 Three persons:         6
 Four persons:         24
 Five persons:        120
 Six  persons:        720

The formula is C<x!> where the postfix unary operator C<!>, also known as I<faculty> is defined as:
C<x! = x * (x-1) * (x-2) ... * 1>. Example: C<5! = 5 * 4 * 3 * 2 * 1 = 120>.Run this to see the 100 first C<< n! >>

 perl -MAcme::Tools -le'$i=big(1);print "$_!=",$i*=$_ for 1..100'

  1!  = 1
  2!  = 2
  3!  = 6
  4!  = 24
  5!  = 120
  6!  = 720

t/27_timestuff.t  view on Meta::CPAN

  my $n = int(($h+$l-7*$m+114)/31);
  my $p = ($h+$l-7*$m+114) % 31;
  (++$p,$n);
}
my @diff;
for(1498..1e4){ #1498..1e7 ok also!
  my $e1=join",",easter($_);
  my $e2=join",",EasterSunday($_);
  push @diff, "easter year $_ e1=$e1 e2=$e2" if $e1 ne $e2;
}
ok(@diff==0,'easter formula1 and 2 eq from year 1498 to 10000');

#--time_fp
ok( time_fp() =~ /^\d+\.\d+$/ , 'time_fp' );

#--sleep_fp
sleep_fp(0.01); #init, require Time::HiRes
my $tfp=time_fp();
sleep_fp(0.1);
my $diff=abs(time_fp()-$tfp-0.1);

t/40_aoh2.t  view on Meta::CPAN

}
my $workbook = Spreadsheet::WriteExcel->new('/tmp/40_aoh2.xls');
my $worksheet = $workbook->add_worksheet();
my $format = $workbook->add_format(); # Add a format
$format->set_bold();
$format->set_color('red');
$format->set_align('center');
$col = $row = 0;
$worksheet->write($row, $col, 'Hi Excel!', $format);
$worksheet->write(1,    $col, 'Hi Excel!');
# Write a number and a formula using A1 notation
$worksheet->write('A3', 1.2345);
$worksheet->write('A4', '=SIN(PI()/4)');
ok(1);

#wget https://en.wikipedia.org/wiki/List_of_largest_cities_and_towns_in_Tennessee_by_population
#perl -MAcme::Tools -le'print aoh2sql([a2h(ht2t(join("",<>),"listings"))],{name=>"list",fix_colnames=>1})' List_of_largest_cities_and_towns_in_Tennessee_by_population |xz -9e|wcc
#perl -MAcme::Tools -le'print aoh2sql([a2h(ht2t(join("",<>),"listings"))],{drop=>2,name=>"list",fix_colnames=>1})' List_of_largest_cities_and_towns_in_Tennessee_by_population |sqlite3 brb.sqlite



( run in 0.382 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )