$display $description
POD say $fh "This constant can also be accessed through the short name \$$short_name (deprecated)\n" if $short_name; }
sub write_pod_synopsis { my ($fh, ) = @_;
say $fh <<'POD';
=head1 SYNOPSIS
use strict; # important!
use Astro::Constants::MKS qw/:long/;
# to calculate the gravitational force of the Sun on the Earth in Newtons, use GMm/r^2
my $force_sun_earth = GRAVITATIONAL * MASS_SOLAR * MASS_EARTH / ASTRONOMICAL_UNIT**2;
DESCRIPTION
This module provides physical and mathematical constants for use in Astronomy and Astrophysics. The two metric systems of units, MKS and CGS, are kept in two separate modules and are called by name explicitly. It allows you to choose between constants in units of centimetres /grams /seconds with Astro::Constants::CGS and metres /kilograms /seconds with Astro::Constants::MKS.
Short forms of the constant names are included to provide backwards compatibility with older versions based on Jeremy Bailin's Astroconst library and are available through the import tag :short
.
The values are stored in Physical_Constants.xml in the data directory and are mostly based on the 2014 CODATA values from NIST.
The problem with long constants is that they are not interpolated in double quotish situations because they are really inlined functions. The problem with short name constants is that they are not read-only and can be assigned to which will mess up your program.
EXPORT
Nothing is exported by default. Select from the following tags:
POD }
sub write_pod_footer { my ($fh, ) = @_;
say $fh <<POD;
=head1 SEE ALSO
ISSUES
File issues at the Github repository https://github.com/duffee/Astro-Constants/
Using strict
is a must with this code. Any constants you forgot to import will evaluate to 0 and silently introduce errors in your code.
Extending the data set
If you want to add in your own constants or override the factory defaults, run make, edit the PhysicalConstants.xml file and then run dzil build
again. If you have a pre-existing PhysicalConstants.xml file, drop it in place before running dzil build
.
Availability
the original astroconst sites have disappeared
ROADMAP
I plan to deprecate the short names and change the order in which long names are constructed, moving to a noun_adjective format. LIGHT_SPEED and SOLAR_MASS become SPEED_LIGHT and MASS_SOLAR. This principle should make the code easier to read with the most important information coming at the beginning of the name.
ASTROCONST
(Gleaned from the Astroconst home page - http://web.astroconst.org )
Astroconst is a set of header files in various languages (currently C, Fortran, Perl, Java, IDL and Gnuplot) that provide a variety of useful astrophysical constants without constantly needing to look them up.
The generation of the header files from one data file is automated, so you can add new constants to the data file and generate new header files in all the appropriate languages without needing to fiddle with each header file individually.
This package was created and is maintained by Jeremy Bailin. It's license states that it is completely free, both as in speech and as in beer.
DISCLAIMER
No warranty expressed or implied. This is free software. If you want someone to assume the risk of an incorrect value, you better be paying them.
(What would you want me to test for you to depend on this module?)
from Jeremy Bailin's astroconst header files
The Astroconst values have been gleaned from a variety of sources, and have quite different precisions depending both on the known precision of the value in question, and in some cases on the precision of the source I found it from. These values are not guaranteed to be correct. Astroconst is not certified for any use whatsoever. If your rocket crashes because the precision of the lunar orbital eccentricity isn't high enough, that's too bad.
ACKNOWLEDGMENTS
Jeremy Balin, for writing the astroconst package and helping test and develop this module.
Doug Burke, for giving me the idea to write this module in the first place, tidying up Makefile.PL, testing and improving the documentation.
POD }
sub write_constant { my ($fh, $value, $long_name, $short_name) = @_;
say $fh "use constant $long_name => $value;";
say $fh "use constant $short_name => $value;" if $short_name;
}
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 128:
Unknown directive: =method