March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center1 How to write Perl Modules Some practical advice about how to build a perl module.

Slides:



Advertisements
Similar presentations
Purdue University Center for Education and Research in Information Assurance and Security Building a distributed intrusion detection system with Perl Diego.
Advertisements

Mod_perl High speed dynamic content. Definitions Apache – OpenSource httpd server Perl – OpenSource interpreted programming language mod_perl – OpenSource.
05/11/2001 CPT week Natalia Ratnikova, FNAL 1 Software Distribution in CMS Distribution unitFormContent Version of SCRAM managed project.
Objected Oriented Perl An introduction – because I don’t have the time or patience for an in- depth OOP lecture series…
Introduction to MATLAB Northeastern University: College of Computer and Information Science Co-op Preparation University (CPU) 10/22/2003.
Lane Medical Library & Knowledge Management Center Perl Programming for Biologists SESSION 2: Tue Feb 10 th 2009 Yannick Pouliot,
Bioperl modules.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Chapter 55 How to Construct JAR files for Program Distribution.
Network File System (NFS) in AIX System COSC513 Operation Systems Instructor: Prof. Anvari Yuan Ma SID:
Julie McEnery1 Installing the ScienceTools The release manager automatically compiles each release of the Science Tools, it creates a set of wrapper scripts.
Nihilistic to Altruistic The Life of a Perl Module.
JCE A Java-based Commissioning Environment tool Hiroyuki Sako, JAEA Hiroshi Ikeda, Visible Information Center Inc. SAD Workshop.
Input/Output Controller (IOC) Overview Andrew Johnson Computer Scientist, AES Controls Group.
SCRAM Software Configuration, Release And Management Background SCRAM has been developed to enable large, geographically dispersed and autonomous groups.
27/07/2001 Copyright 2001, Munica Corporation, 1 How to write a DBD driver Daini Xie Strathy President Munica Corporation
More Modules Inheritance, Exporting, documentation, testing.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormack 3rd floor 607.
 To explain the importance of software configuration management (CM)  To describe key CM activities namely CM planning, change management, version management.
Operating Systems Lecture 4. Agenda for Today Review of previous lecture Operating system structures Operating system design and implementation UNIX/Linux.
Teach Yourself Windows 95 Module 5: Customizing and Maintaining Your Computer.
How to Tag a Corpus Using Stanford Tagger. Accuracy All tokens: 97.32% Unknown words: 90.79%
Java Introduction to JNI Prepared by Humaira Siddiqui.
Copyright © 2011, SAS Institute Inc. All rights reserved. Using the SAS ® Clinical Standards Toolkit 1.4 to work with the CDISC ODM model Lex Jansen SAS.
1 Using Modules. 2 Modules A Perl module is a collection of subroutines and variables that typically implements some common functionality – and "packaged"
Writing Perl Extensions: There’s more than one way to do it.
Managing Software Patches 10/15/ Introducing Solaris OE Patches A patch contains collection of files and directories Patch replaces existing files.
Python From the book “Think Python”
CSC 230: C and Software Tools Rudra Dutta Computer Science Department Course Introduction.
0 eCPIC User Training: Resource Library These training materials are owned by the Federal Government. They can be used or modified only by FESCOM member.
Installing CompuCell3D from source Maciej Swat Biocomplexity Institute, Indiana University.
SYSTEMSDESIGNANALYSIS 1 OO: Chapter 9 Visual Basic: Building Components Jerry Post Copyright © 1999.
AIP Backup & Restore Sunita Barve NCRA, Pune. AIP The latest version of DSpace 1.7.0, supports backup and restore of all its contents as a set of AIP.
Working with arrays (we will use an array of double as example)
How to write & use Perl Modules. What is a Module? A separate Namespace in a separate file with related functions/variables.
Processes Introduction to Operating Systems: Module 3.
This document gives one example of how one might be able to “fix” a meteorological file, if one finds that there may be problems with the file. There are.
Programming Perl in UNIX Course Number : CIT 370 Week 6 Prof. Daniel Chen.
GLite build and integration system Building and Packaging Robert HARAKALY
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
ASIS + RPM: ASISwsmp German Cancio, Lionel Cons, Philippe Defert, Andras Nagy CERN/IT Presented by Alan Lovell.
Module 1 - Introduction to Linux. Users must log-in Linux is case sensitive File and Directories naming conventions (No spaces!) Files and Directories.
Yannick Patois - Datagrid Software Repository Presentation - March, n° 1 Datagrid Software Repository Presentation CVS, packages and automatic.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
Microsoft ® Official Course Module 6 Managing Software Distribution and Deployment by Using Packages and Programs.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Appendix I: Getting Started with Web Servers, PHP and the.
Perl Subroutines User Input Perl on linux Forks and Pipes.
 Prepared by: Eng. Maryam Adel Abdel-Hady
 Prepared by: Eng. Maryam Adel Abdel-Hady
Integrating ArcSight with Enterprise Ticketing Systems
Introduction to Bioinformatic Computation. Lecture
BIF713 Managing Disk Space.
A Replica Location Service
Introduction to Bioinformatic Computation. Lecture
WORKSHOP 3 GSE IMPORT.
Perl Modules.
The Linux Command Line Chapter 2
3 Macro Storage.
Modules A Perl module is a self-contained piece of Perl code that can be used by a Perl program or by other Perl modules. It is conceptually similar to.
The Application Lifecycle
Loaders and Linkers: Features
Tivoli Common Reporting v1.2 Overview
Operating Systems Lecture 4.
Electronics II Physics 3620 / 6620
CMPE212 – Reminders Assignment 2 due today, 7pm.
Graphing Using Processing
GENEDI EUROPEAN COMMISSION - EUROSTAT GENERIC EDI TOOLBOX
STATEL an easy way to transfer data
Presentation transcript:

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center1 How to write Perl Modules Some practical advice about how to build a perl module March 21, 2003 – Stanford Linear Accelerator Center Fabrizio Coccetti

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center2Agenda What a Perl Module is Why it is convenient to use Perl Modules How to make Perl Modules An example of a Perl Module Preparing the package for shipping Perl Module are easy to make and handy to use

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center3 What a Perl Module is A Perl Module is a self-contained piece of [Perl] code that can be used by a Perl program (or by other Perl modules) It is conceptually similar to: a C link library a C++/Java class

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center4 Why it is convenient to use PMs Installation is straightforward: perl Makefile.PL; make; make install The Perl interpreter has a list of directories in which it searches for modules (global Installation is platform independent (Solaris, Linux, Windows, …) Easy to use in Perl Programs: use IPEM::PingER Easy to update both for the maintainers of a Perl Module and system administrators at remote sites Time saving technique !!

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center5 Before making a PM Chose an appropriate name for the PM Each Perl Module has an unique name. Perl provides a hierarchal name space for modules, similar to the name space for Java classes. Components of a module name are separated by double colons “::”. i.e. IEPM::PingER

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center6 Let’s start to make a Perl Module Create the Perl Module Tree: -A omits the Autoloader code (best used by modules that define a large number of infrequently used subroutines) -X omits XS elements (eXternal Subroutine, where eXternal means external to Perl, i.e. C) -n specifies the name of the module $ h2xs -AX -n IEPM::PingER

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center7 What h2xs does for the developer Creates subdirs:./IEPM/PingER/ Creates the following files and the t/ dir: Changes Makefile.PL MANIFEST (contains the list of all files in the package ) README t/ (test files) PingER.pm (perl code goes here)

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center8 Some advice on writing the code of a PM A PM can use other PMs use strict; (i.e. $IEPM::PingER::var) use 5.6.1; = qw(ping_it); sub ping_it {… … …} 1; __END__

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center9 How to use a PM in a Perl program Another way is to in the Perl = qw(ping_it log_it); And in the Perl Program use IEPM::PingER qw(log_it) use IEPM::PingER; $answer = ping_it (host.domain.edu);

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center10 Use Carp in Perl Modules The Carp module allows to present error messages from the caller's perspective warn "No hostname given"; No hostname given at /usr/local/lib/perl5/site_perl/5.6/IEPM/PingER.pm line 143. carp "No hostname given"; No hostname given at perl_script.pl line 5. use Carp; warn carp die croak Recipe:

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center11 Example: the beginning of IEPM::PingER package IEPM::PingER; use 5.008; use strict; use warnings; use Carp; require Exporter; = qw(Exporter); use Time::CTime; use DB_File; = qw(log_it ping_it); our $VERSION = '1.03';

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center12 Example: the subroutine ping_it PingER.PM sub ping_it { my ($ping_cmd,$dest_name,$dest_ip, $ping_interval, $ping_size, $ping_count) … … … … return ($time, $packets_sent, $packets_rcvd, $min, $avg, $max, } timeping.pl use IEPM::PingER; ($time, $packets_sent, $packets_rcvd, $min, $avg, $max, $seqno, $pingtimes) = ping_it($ping_cmd,$dest_name,$dest_ip, $ping_interval, 1000, $ping_count);

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center13 Preparing the package for shipping Prepare the package for shipping is straightforward: $ perl Makefile.PL; make; make dist; The commands above create the compressed archive: IEPM-PingER-1.03.tar.gz

March 21, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center14References Perl Module Mechanics The Perl Module Library Perl Modules The Perl 5 Modules List Practical Perl Programming Perlnewmod - preparing a new module for distribution