User Tools

Site Tools


newdevs:perl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
newdevs:perl [2024/01/18 09:48] – [Using Cstore to interact with the database] Add a bunch of examples sandbergjanewdevs:perl [2024/01/18 10:11] (current) – fix headings, add a link sandbergja
Line 2: Line 2:
 ====== The Perl Logic Layer ====== ====== The Perl Logic Layer ======
  
 +===== Structure =====
  
- 
- 
- 
-==== Structure ==== 
  
 Most of Evergreen's business logic can be found in perl modules.  In the git repository, these can be found at Open-ILS/src/perlmods/lib.  Perl modules typically have the .pm file extension. Most of Evergreen's business logic can be found in perl modules.  In the git repository, these can be found at Open-ILS/src/perlmods/lib.  Perl modules typically have the .pm file extension.
Line 14: Line 11:
 There are many Perl scripts throughout the project.  Perl scripts generally have the .pl file extension. There are many Perl scripts throughout the project.  Perl scripts generally have the .pl file extension.
  
-==== Dependencies ====+===== Dependencies =====
  
 Evergreen's Perl code relies on many packages from CPAN.  They are installed by your operating system's package manager and cpan itself when you run the Open-ILS/src/extras/Makefile.install Makefile.  When you need to add or remove a dependency, do so for all of the operating systems listed in the Open-ILS/src/extras/install directory. Evergreen's Perl code relies on many packages from CPAN.  They are installed by your operating system's package manager and cpan itself when you run the Open-ILS/src/extras/Makefile.install Makefile.  When you need to add or remove a dependency, do so for all of the operating systems listed in the Open-ILS/src/extras/install directory.
  
-==== Checking your work ====+===== Checking your work =====
  
 Here are some things you can do to check your work while working with Evergreen's perl code: Here are some things you can do to check your work while working with Evergreen's perl code:
  
-  * If it is in an OpenSRF method: Build it, install it, and restart your services.  Then call the method (through the UI, or directly using the srfsh).  Confirm that the behavior is what you expected. +  * If it is in an OpenSRF method: Build it, install it, and restart your services.  Then call the method (through the UI, or directly using the srfsh).  Confirm that the behavior is what you expected
 +     * To build and install the perl code, you can run ''make'' as opensrf then ''make install'' as root.  Alternatively, you can build and install the perl code in a single step with ''cd Open-ILS/src/perlmods && ./Build install'' as root.
   * Write some tests to confirm that your code is working as intended, without any unintended side effects.   * Write some tests to confirm that your code is working as intended, without any unintended side effects.
-  * Run `perl -cw [name of file]to check your syntax and check for warnings. +  * Run ''perl -cw [name of file]'' to check your syntax and check for warnings. 
-  * Run perlcritic on your code to check for common gotchas and readability.  You can paste your code directly into [[http://perlcritic.com/|the online PerlCritic checker]].  This is not a requirement (most perl code in Evergreen violates these rules), but it can be very instructive.+  * Run perlcritic on your code to check for common gotchas and readability.  You can paste your code directly into [[http://perlcritic.com/|the online PerlCritic checker]] or install the command line tool from CPAN.  This is not a requirement (most perl code in Evergreen violates these rules), but it can be very instructive.
   * Temporarily adding print or logging statements to your work.  If you'd like to print an array or hash, try using Data::Dumper.   * Temporarily adding print or logging statements to your work.  If you'd like to print an array or hash, try using Data::Dumper.
  
-==== Using Cstore to interact with the database ====+===== Using Cstore to interact with the database =====
  
 A lot of the Perl code uses a Cstore editor to create, retrieve, update, delete, and search records in the database.  The following examples are loosely based on the Carousel Perl module: A lot of the Perl code uses a Cstore editor to create, retrieve, update, delete, and search records in the database.  The following examples are loosely based on the Carousel Perl module:
Line 65: Line 63:
   $carousel->max_items(12);   $carousel->max_items(12);
   $carousel->bucket(30);   $carousel->bucket(30);
 +  
   # Then, start a transaction in the database.  This is   # Then, start a transaction in the database.  This is
   # required any time you are changing data in the database   # required any time you are changing data in the database
Line 132: Line 130:
      
   1;   1;
-==== Evergreen Conference Sessions ====+ 
 +===== Evergreen Conference Sessions =====
   * [[https://www.youtube.com/watch?v=fXrhpJUpFWE&ab_channel=EvergreenLibrarySystem|Making Perl Work for You in Evergreen, by Galen Charlton & Mike Rylander]]   * [[https://www.youtube.com/watch?v=fXrhpJUpFWE&ab_channel=EvergreenLibrarySystem|Making Perl Work for You in Evergreen, by Galen Charlton & Mike Rylander]]
 +
 +===== Further Reading =====
 +
 +  * [[http://www.perlmeme.org/howtos/using_perl/dereferencing.html|Dereferencing in Perl]] from perlmeme.org
newdevs/perl.1705589285.txt.gz · Last modified: 2024/01/18 09:48 by sandbergja

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.