CPAN

From GnuCash
Jump to: navigation, search

Comprehensive Perl Archive Network (CPAN) is the standard tool to manage perl programs and modules on your computer. Because GnuCash uses the perl module Finance::Quote to retrieve prices for securities and exchange rates for currencies, it can be useful to have some knowledge of this tool beneath the Gnucash specific gnc-fq-* scripts.

Perl includes a cpan program to interact with the CPAN database and to download, build, and install modules and programs.

Administrative Access

By default they're installed in system directories so it's necessary to call cpan with administrative (a.k.a. root) privileges. On Unix system (including Apple MacOS) one uses the sudo ("switch-user-do") command wrapper, as in

 sudo cpan -i Finance::Quote

that will install the Finance::Quote module and everything it needs. N.B. at the time this is written GnuCash also requires the Date::Manip module.

In general one must have a user id that's authorized to manage the computer's settings in order to use sudo.

cpan setup

The first time you run cpan it will need to configure some internal modules, learn about your network, and have you designate the cpan mirrors to use. It runs a script to do this and provides defaults that are nearly always right so you can just run through the script accepting all of the defaults.

Using cpan to install modules

On Unix systems (including MacOS) cpan retrieves source archives of modules and if necessary compiles them on your system. That means that you will need at least a compiler and the basic development libraries for your system. On Linux and BSD systems you may need to install these with your package manager. On MacOS the system will offer to install the Command Line Developer Tools if you don't already have either them or Xcode installed.

Microsoft Windows

Unlike Unix-based operating systems Microsoft Windows doesn't include the Perl language, so GnuCash provides a menu item, "Install Online Quote Retrieval" that runs a script to install a Perl package (Strawberry Perl) and all of the Finance::Quote requirements. Strawberry Perl includes all of the components needed for cpan so that there's no need to separately install a compiler. It also doesn't install modules into system directories so administrative privileges are generally not required. The Strawberry Perl Start Menu folder includes a cpan terminal item that launches a cpan shell correctly configured for the Strawberry Perl installation.

gnc-fq-update

GnuCash provides a Perl program, gnc-fq-update that will run cpan for you and install all of the Perl modules currently required. As noted above the first time you do this it will run the setup script in which you can simply accept all of the defaults.