1 / 111

What Perl can do for you

What Perl can do for you. Phil Shirley Cuyahoga Falls Library. Goals. 1. Learn about the process of running a Perl script So you can speak intelligently with an IT person who you want to do some Perl So you can try it yourself if you want. Goals. 2. Learn how libraries use Perl

xuan
Download Presentation

What Perl can do for you

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What Perl can do for you Phil Shirley Cuyahoga Falls Library

  2. Goals 1. Learn about the process of running a Perl script • So you can speak intelligently with an IT person who you want to do some Perl • So you can try it yourself if you want

  3. Goals 2. Learn how libraries use Perl • Understand how some scripts basically work • Appreciate the more complex projects • Grasp the scope of what Perl can do

  4. This presentation will not teach you anything about the Perl programming language or how to write, edit, or troubleshoot Perl scripts

  5. Overview • What is Perl • What you need • Beyond the basics • What libraries are doing with Perl • Resources

  6. Dear computer, Please take that file I just saved and give me a summary report. kthxbye

  7. “Great, somebody posted a Perl script to do exactly what I need! I wish I knew how to use it.”

  8. “We don’t have Perl.”

  9. What Perl Is Perl is a general purpose programming language that’s especially good at manipulating text.

  10. Script? Program? • Scripts and programs are changed (“compiled”) into commands the computer can understand. • Scripts are compiled each time you run them. • Programs are compiled once, when you finish writing them.

  11. Still, we use the word “programming” to refer to creating scripts.

  12. Some write it “PERL” • “Practical Extraction and Report Language” • Actually this is a backronym, just like “Gentlemen Only, Ladies Forbidden” (Golf).

  13. What do I need to get started? • A computer • A text editor • A Perl script • A Perl interpreter • Perl modules (if needed by the script) • Input

  14. Computer • Your workstation (Windows, Mac, etc.) • Just about any server (web, e-mail, Windows, etc.) • Almost never your Innovative server

  15. Which computer you use depends on the particular task and/or what computers you have access to.

  16. Text editor • For creating & editing Perl scripts • A program for editing plain text files • letters, numerals, symbols, tab, newline • no fileformat-specific control characters for things like bold, italic, fonts, columns, tables

  17. Text Editors • Not Microsoft Word, Wordpad, etc. • Built-in: • Notepad (Windows) • SimpleText or TextEdit (Mac) • Other specialized editors for programming exist

  18. Perl script • A plain text file that you write (or copy from somebody else) • Written in the Perl language • Looks like this:

  19. #!c:\perl\bin\perl.exe print "Hello World!";

  20. Perl interpreter • A program you install on the computer where you’ll run scripts • Changes the script into instructions the computer can understand • Free!

  21. Perl Interpreter: Active Perl http://www.activestate.com/Products/activeperl/index.mhtml

  22. Perl modules • Extend the language • Make it easier to do some kind of task • Examples • Net::FTP • XML::Parser • MARC::Record

  23. Input • A text file that you want the script to do something with • A script can also get some info from the computer (like date & time)

  24. Output • A text file created by the Perl script • Could be HTML, XML, MARC, RSS feed, etc. • Or, could be just something normal for you to look at, print, paste into a report, etc.

  25. In summary, the components • A computer • A text editor • A Perl script • A Perl interpreter • Perl modules if needed by the script • Input • [Output – created by the Perl script]

  26. Questions so far?

  27. Beyond the Basics • If you want, and you have everything you need for this, you can automate the running of scripts. • Some libraries automate the running of Create Lists, process the output with a Perl script, and output an HTML file directly on their web servers. • Of course, you can create and post a web page without doing it this way.

  28. Beyond the basics:Expect An Expect script logs into the character-based system, runs Create Lists, and produces the input for a Perl script.

  29. Actually, Expect scripts can do just about anything in the character-based system.

  30. Beyond the basics:Scheduling an Expect script • UNIX: cron • Windows: Scheduled Tasks

  31. Beyond the basics:E-mail pipe method • UNIX mail servers only (probably) • Receives e-mail and uses /etc/aliases file to “pipe” the e-mail to a Perl script on that server

  32. Beyond the basics: Output • Save the output file to the live directory on a web server or intranet server. • It’s easier if your mail and web are on the same server.

  33. Beyond the basics,putting it all together: Scheduling + Expect + email pipe method + web server

  34. Other advanced uses • Using a Perl script to: • Construct a database • Query a database • Interact with another script • Communicate with another computer

  35. What Libraries Are Doing with Perl • Create Lists • Prepare Bib & Patron Data for Loading • OPAC functionality • Circulation • System administration

  36. Create Lists: How Perl Can Help • Reformat the output of Create Lists to: • Create a web page. • Create an RSS feed. • Etc.

  37. Create Lists: How Perl Can Help • Bring out data that Create Lists can't display. • Further refine your Create Lists query. • Save the data in a different database (like MySQL).

  38. Simple Examples of Using Perl with Create Lists for the Public

  39. Creates a web page that’s a list of circulating videos from Create Lists output http://library.mills.edu/screens/videocirc.html Mills College Script available from Alma Garcia (almag@mills.edu)

  40. Creates a web page that’s a list of journals based on output from Create Lists http://www.scripps.edu/library/open/all.html The Scripps Research Institute

  41. Creates an A-Z list of periodicals http://library.truman.edu/search_articles/ electronic-journals.htm Stephen Wynn Truman State University Script available from swynn@truman.edu

  42. Generates new items RSS feeds from create lists output. http://library.bury.gov.uk/screens/new_items_feeds.html Alan Brown Bury Libraries Script available at http://www.innovativeusers.org/ cgi-bin/clearinghouse/view.pl?id=166

  43. Creates web pages and RSS feeds of recent acquisitions grouped by broad subject area, department/program, and call number http://library.lafayette.edu/collections/newacq Bob Duncan Lafayette College Script available from duncanr@lafayette.edu

  44. More Complex Examples of Using Perl with Create Lists for the Public

More Related