Writing Perl Modules for CPAN

Total Page:16

File Type:pdf, Size:1020Kb

Writing Perl Modules for CPAN Writing Perl Modules for CPAN SAM'IREGAR APress Media, LLC Writing PerI Modules for CPAN Copyright ©2002 by Sam Tregar Origina1ly published by Apress in 2002 AH rights reserved. No part ofthis woIk may be reproduced or transmitted in any fonn or by any means, electronic or mechanica1, including photocopying, recording, or by any infonnation storage or retrieva1 system, without the priorwritten pennission ofthe copyright owner and the publisher. ISBN 978-1-59059-018-8 ISBN 978-1-4302-1152-5 (eBook) DOI 10.1007/978-1-4302-1152-5 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement ofthe trademark. Technical Reviewers: Tesse Erlbaum and Neil Watkiss Editorial Directors: Dan Appleman, Gary Cornell, Tason Gilmore, Simon Hayes, Karen Watterson, Tohn Zukowski Managing Editor and Production Editor: Grace Wong Project Managers: Erin Mulligan, Alexa Stuart Copy Editor: Ami Knox Proofreader: Brendan Sanchez Compositor: Susan Glinert Indexer: Valerie Perry Caver Designer: Kurt Krames Manufacturing Manager: Tom Debolski Marketing Manager: Stephanie Rodriguez The infonnation in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author nor Apress shall have any liability to any person or entity with respect to any 10ss or damage caused or alleged to be caused directly or indirectly by the infonnation contained in this work. In memory ofLuke and to Kristen who introduced us Contents at a Glance About the Author ................................................................................................. xi About the Technical Reviewers ................................................................ xiii Acknowledgments ...................................................................................................xv Introduction .................... ~ ................................................................................. xvii Chapter 1 CPAN ............................................................................................... 1 Chapter 2 Per1 Module Basics ............................................................... 21 Chapter 3 Module Design and Implementation ................................ 65 Chapter 4 CPAN Module Distributions ............................................... 95 Chapter 5 Submitting Your Module to CPAN ................................... 129 Chapter 6 Module Maintenance ............................................................. 139 Chapter 7 Great CPAN Modules ............................................................. 165 Chapter 8 PrograRITiing Per1 in C ...................................................... 175 Chapter 9 Writing C Modules with XS ............................................. 205 Chapter 10 Writing C Modules with Inline: :C .............................. 237 Chapter 11 CGI Application Modules for CPAN .............................. 253 Index ...................................................................................................................... 273 V Contents About the Author .......................................................................................... xi About the Technical Reviewers .................................................... xiii Acknowledgments ............................................................................................. xv Introduction ................................................................................................. xvii What You Need to Know .................................................................................... xxi System Requirements ....................................................................................... xxii Per1 Version ...................................................................................................... xxii Chapter 1. CPAN ............................................................................................. 1 Why Contribute to CPAN? .................................................................................. 1 Netlit/Ork Topology .................................................................................................. 3 Browsing CPAN ......................................................................................................... 6 Searching CPAN .................................................................................................... 12 Installing CPAN Modules ................................................................................ 13 ActivePerl PPM .................................................................................................... 19 Bundles ................................................................................................................... 20 CPAN' s Future ...................................................................................................... 20 Sununary ................................................................................................................... 20 Chapter 2 Perl Module Basics ....................................................... 21 Using Modules ...................................................................................................... 22 Packages ................................................................................................................. 24 Modules ................................................................................................................... 27 Read the Fine Manuals ..................................................................................... 64 Summary ................................................................................................................... 64 vii Contents Chapter 3 Module Design and Implementation ................... 65 Check Your Slack ................................................................................................ 65 Size Matters ......................................................................................................... 66 Document First ..................................................................................................... 66 Interface Design ................................................................................................ 73 Summary .................................................................................................................... 94 Chapter 4 CPAN Module Distributions ..................................... 95 Module Installation .......................................................................................... 95 Always Begin with h2xs ................................................................................... 98 Exploring the Distribution ......................................................................... 112 Portability ......................................................................................................... 122 Choosing a License .......................................................................................... 126 Summary .................................................................................................................. 128 Chapter 5 Submitting Your Module to CPAN ...................... 129 Requesting Comments ........................................................................................ 129 Requesting a CPAN Author ID ...................................................................... 131 Registering Your Namespace ......................................................................... 132 Uploading Your Module Distribution ....................................................... 134 Post-Upload Processing ................................................................................. 137 Summary .................................................................................................................. 138 Chapter 6 Module Maintenance ..................................................... 139 Growing a User Community ............................................................................. 139 Managing the Source ........................................................................................ 142 Making Releases ................................................................................................. 161 Summary .................................................................................................................. 163 Chapter 7 Great CPAN Modules ..................................................... 165 Hhat Makes a Great CPAN Module? .............................................................. 165 CGI.pm .................................................................................................................... 166 OBI ........................................................................................................................... 168 Storable ................................................................................................................ 169 Net: :FTP ................................................................................................................ 170 LHP ........................................................................................................................... 171 XML : :SAX ...............................................................................................................
Recommended publications
  • MANNING Greenwich (74° W
    Object Oriented Perl Object Oriented Perl DAMIAN CONWAY MANNING Greenwich (74° w. long.) For electronic browsing and ordering of this and other Manning books, visit http://www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. 32 Lafayette Place Fax: (203) 661-9018 Greenwich, CT 06830 email: [email protected] ©2000 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Library of Congress Cataloging-in-Publication Data Conway, Damian, 1964- Object oriented Perl / Damian Conway. p. cm. includes bibliographical references. ISBN 1-884777-79-1 (alk. paper) 1. Object-oriented programming (Computer science) 2. Perl (Computer program language) I. Title. QA76.64.C639 1999 005.13'3--dc21 99-27793 CIP Manning Publications Co. Copyeditor: Adrianne Harun 32 Lafayette
    [Show full text]
  • Java Bytecode Manipulation Framework
    Notice About this document The following copyright statements and licenses apply to software components that are distributed with various versions of the OnCommand Performance Manager products. Your product does not necessarily use all the software components referred to below. Where required, source code is published at the following location: ftp://ftp.netapp.com/frm-ntap/opensource/ 215-09632 _A0_ur001 -Copyright 2014 NetApp, Inc. All rights reserved. 1 Notice Copyrights and licenses The following component is subject to the ANTLR License • ANTLR, ANother Tool for Language Recognition - 2.7.6 © Copyright ANTLR / Terence Parr 2009 ANTLR License SOFTWARE RIGHTS ANTLR 1989-2004 Developed by Terence Parr Partially supported by University of San Francisco & jGuru.com We reserve no legal rights to the ANTLR--it is fully in the public domain. An individual or company may do whatever they wish with source code distributed with ANTLR or the code generated by ANTLR, including the incorporation of ANTLR, or its output, into commerical software. We encourage users to develop software with ANTLR. However, we do ask that credit is given to us for developing ANTLR. By "credit", we mean that if you use ANTLR or incorporate any source code into one of your programs (commercial product, research project, or otherwise) that you acknowledge this fact somewhere in the documentation, research report, etc... If you like ANTLR and have developed a nice tool with the output, please mention that you developed it using ANTLR. In addition, we ask that the headers remain intact in our source code. As long as these guidelines are kept, we expect to continue enhancing this system and expect to make other tools available as they are completed.
    [Show full text]
  • Intermediate Perl
    SECOND EDITION Intermediate Perl Randal L. Schwartz, brian d foy, and Tom Phoenix Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo Intermediate Perl, Second Edition by Randal L. Schwartz, brian d foy, and Tom Phoenix Copyright © 2012 Randal Schwartz, brian d foy, Tom Phoenix. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected]. Editors: Simon St. Laurent and Shawn Wallace Indexer: Lucie Haskins Production Editor: Kristen Borg Cover Designer: Karen Montgomery Copyeditor: Absolute Service, Inc. Interior Designer: David Futato Proofreader: Absolute Service, Inc. Illustrator: Rebecca Demarest March 2006: First Edition. August 2012: Second Edition. Revision History for the Second Edition: 2012-07-20 First release See http://oreilly.com/catalog/errata.csp?isbn=9781449393090 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Intermediate Perl, the image of an alpaca, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein.
    [Show full text]
  • Netapp Snap Creator Framework
    Notice About this information The following copyright statements and licenses apply to open source software components that are distributed with various versions of the NetApp Snap Creator for framework software products. Your product does not necessarily use all the open source software components referred to below. Where required, source code is published at the following location: ftp://ftp.netapp.com/frm-ntap/opensource/ Copyrights and licenses The following component is subject to the Crypt DES CPAN License: ◆ Crypt::DES 2.05 Copyright © 2000 W3Works, LLC. All rights reserved Copyright © 1995, 1996 Systemics Ltd (http://www.systemics.com/).All rights reserved. This perl extension includes software developed by Eric Young ([email protected]) Modifications, including cross-platform fixups, and single-algorithm distribution packaging are Copyright © 2000 W3Works, LLC. All Rights Reserved. Mail questions and comments to Dave Paris <[email protected]>. Original distribution license (below) applies. Other parts of the library are covered by the following licence: Copyright © 1995, 1996 Systemics Ltd (http://www.systemics.com/) All rights reserved. This library and applications are FREE FOR COMMERCIAL AND NON-COMMERCIAL USE as long as the following conditions are adhered to. Copyright remains with Systemics Ltd, and as such any Copyright notices in the code are not to be removed. If this code is used in a product, Systemics should be given attribution as the author of the parts used. This can be in the form of a textual message at program startup or in documentation (online or textual) provided with the package. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.
    [Show full text]
  • Tape Automation Scalar Key Manager, Software Release 2.4 Open Source Software Licenses
    Tape Automation Scalar Key Manager, Software Release 2.4 Open Source Software Licenses Open Source Software (OSS) Licenses for: • Scalar Key Manager, Software Release 2.4. The software installed in this product contains Open Source Software (OSS). OSS is third party software licensed under separate terms and conditions by the supplier of the OSS. Use of OSS is subject to designated license terms and the following OSS license disclosure lists the open source components and applicable licenses that are part of the Scalar Key Manager. The Scalar Key Manager, Software Release 2.4, is delivered with Ubuntu 12.04 as a base operat- ing system. Individual packages that comprise the Ubuntu distribution come with their own li- censes; the texts of these licenses are located in the packages' source code and permit you to run, copy, modify, and redistribute the software package (subject to certain obligations in some cases) both in source code and binary code forms. The following table lists open-source software components used in the Scalar Key Manager® release 2.4 that have been added to the base operating system, patched, or otherwise included with the product. For each component, the associated licenses are provided. Upon request, Quan- tum will furnish a DVD containing source code for all of these open-source modules for the ad- ditional packages listed here. The source for the ubuntu-12.04.5-alternate-amd64.iso can current- ly be found at: http://cdimage.ubuntu.com/releases/12.04/release/source/ To order a copy of the source code covered by an open source license, or to obtain information and instructions in support of any open source license terms, contact the Global Call Center: • In the USA, call 1-800-284-5101.
    [Show full text]
  • So You Want to Write About Perl! Brian D Foy, [email protected] Publisher, the Perl Review YAPC Chicago 2006 About Me Wrote My first Perl Article for TPJ #9
    So You Want to Write about Perl! brian d foy, [email protected] Publisher, The Perl Review YAPC Chicago 2006 About me Wrote my first Perl article for TPJ #9 Then my next for TPJ #11 (Got into The Best of The Perl Journal) Later a columnist for TPJ O’Reilly Weblogger, MacDevCenter, &c. Publisher of The Perl Review Lead author of Learning Perl, 4th Edition Lead author of Intermediate Perl Working on Mastering Perl Reasons Not to Write Get rich Have more free time Quality time with your computer Free international travel Reasons To Write Your story is Perl’s best advocacy Learn more about Perl Become a better writer and communicator Let people know what you’re doing Let people (Google) know who you are Write now You can start right away Blogs use.perl.org Perlmonks Meditations Fancier Places Perl.com IBM Developer Works The Perl Review Dr. Dobbs, Linux Magazine, Unix Review Getting the Gig It’s who you know, mostly Or you have to have something really good Most places won’t be encouraging Find the right people Have some samples Publishers want Interesting content Good writing The least hassle Writers with whom they can work Something that sells Wanting the Gig People need to see your work Your publisher should promote you Your writing should take center stage Be careful about writing for free Talk to other authors about contracts and publishers Published other things you like Introducing yourself Most places have some sort of author or style guide with instructions When you propose something, be concise and to the point Realize that lots
    [Show full text]
  • Perl Hacks Tips and Tools for Programming Debugging And
    Perl Hacks By chromatic , Damian Conway, Curtis "Ovid" Poe ............................................... Publisher: O'Reilly Pub Date: May 2006 Print ISBN-10: 0-596-52674-1 Print ISBN-13: 978-0-59-652674-0 Pages: 296 Table of Contents | Index With more than a million dedicated programmers, Perl has proven to be the best computing language for the latest trends in computing and business. While other languages have stagnated, Perl remains fresh thanks to its community-based development model, which encourages the sharing of information among users. This tradition of knowledge-sharing allows developers to find answers to almost any Perl question they can dream up. And you can find many of those answers right here in Perl Hacks. Like all books in O'Reilly's "Hacks" series, Perl Hacks appeals to a variety of programmers, whether you're a experienced developer or a dabbler who simply enjoys exploring technology. Each hack is a short lesson - some are practical exercises that teach you essential skills, while others merely illustrate some of the fun things that Perl can do. Most hacks have two parts: a direct answer to the immediate problem you need to solve right now and a deeper, subtler technique that you can adapt to other situations. Learn how to add CPAN shortcuts to the Firefox web browser, read files backwards, write graphical games in Perl, and much more. For your convenience, Perl Hacks is divided by topic - not according to any sense of relative difficulty - so you can skip around and stop at any hack you like. Chapters include: Productivity Hacks User Interaction Data Munging Working with Modules Object Hacks Debugging Whether you're a newcomer or an expert, you'll find great value in Perl Hacks, the only Perl guide that offers something useful and fun for everyone.
    [Show full text]
  • Learning Perl 6.Pdf
    Learning Perl 6 KEEPING THE EASY, HARD, AND IMPOSSIBLE WITHIN REACH brian d foy www.allitebooks.com www.allitebooks.com Learning Perl 6 Keeping the Easy, Hard, and Impossible Within Reach brian d foy Beijing Boston Farnham Sebastopol Tokyo www.allitebooks.com Learning Perl 6 by brian d foy Copyright © 2018 brian d foy. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/insti‐ tutional sales department: 800-998-9938 or [email protected]. Editor: Jeff Bleiel Indexer: Lucie Haskins Production Editor: Nicholas Adams Interior Designer: David Futato Copyeditor: Rachel Head Cover Designer: Karen Montgomery Proofreader: Kim Cofer Illustrator: Rebecca Demarest September 2018: First Edition Revision History for the First Edition 2018-08-24: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491977682 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Learning Perl 6, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the author, and do not represent the publisher’s views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work.
    [Show full text]
  • Software Components That Are Distributed with Various Versions of the Data ONTAP Products
    Notice About this document The following copyright statements and licenses apply to software components that are distributed with various versions of the Data ONTAP products. Your product does not necessarily use all the software components referred to below. Where required, source code is published at the following location: ftp://ftp.netapp.com/frm-ntap/opensource/ 215-08562_A0 -Copyright 2013 NetApp, Inc. All rights reserved. 1 Notice Copyrights and licenses The following component is subject to the ASM License • ASM - 2.2 Copyright (c) 2000-2005 INRIA, France Telecom All rights reserved. ASM: a very small and fast Java bytecode manipulation framework Copyright (c) 2000,2002,2003 INRIA, France Telecom All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. • Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    [Show full text]
  • Syllabus for Computation for the Life Sciences CS 5046, Spring 2007 Meeting Times 206A Randolph Hall, TR 11AM–12:15PM Instructor T
    Syllabus for Computation for the Life Sciences CS 5046, Spring 2007 Meeting times 206A Randolph Hall, TR 11AM–12:15PM Instructor T. M. Murali Office 2160B Torgerson Hall Office hours 1–3PM Tuesday and by appointment Email [email protected] Mailing list CS5046 [email protected] WWW http://courses.cs.vt.edu/~cs5046 Description This course is the second part of a two-course introduction to computer science designed for graduate students enrolled in a life science department or the Ph.D. programme in Genetics, Bioinformatics, and Computational Biology but not having a computer science background. It builds upon the background developed in CS 5045. The first part of the course introduces students to object-oriented programming using the Perl language and teaches them basic principles of software engineering. The second part of the course deals with the design, analysis and implementation of fundamental algorithms and data structures. The course ends with special topics in Perl of relevance to life science students interested in doing research in bioinformatics and computational biology. Pre-requisites You must have graduate standing in a Life Science department or GBCB. CS 5045 is a pre-requisite for this course. Please talk to me if you have not taken CS5045. You cannot use this course to obtain CS major or minor credit. The course is not open to students with graduate standing in the CS programme. Textbooks Required • Mastering Perl for Bioinformatics, James Tisdall, O’Reilly & Associates, 2003. Recommended • Object Oriented Perl, Damien Conway, Manning Publications Co., 2000. Useful • Perl Best Practices, Damian Conway, O’Reilly & Associates, 2005.
    [Show full text]
  • License Informatino User Manual
    Oracle® Communications Diameter Intelligence Hub Licensing Information User Manual Release 1.2 E62998 Revision 1 April 2015 Copyright © 2013,2015 Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are “commercial computer software” pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs.
    [Show full text]
  • From Upstream's LICENSES File 8X
    ------------- Further details on licensing: From upstream's LICENSES file 8X--------------------------------------------------- Additional license notices for Libgcrypt. -*- org -*- This file contains the copying permission notices for various files in the Libgcrypt distribution which are not covered by the GNU Lesser General Public License (LGPL) or the GNU General Public License (GPL). These notices all require that a copy of the notice be included in the accompanying documentation and be distributed with binary distributions of the code, so be sure to include this file along with any binary distributions derived from the GNU C Library. * BSD_3Clause For files: - cipher/sha256-avx-amd64.S - cipher/sha256-avx2-bmi2-amd64.S - cipher/sha256-ssse3-amd64.S - cipher/sha512-avx-amd64.S - cipher/sha512-avx2-bmi2-amd64.S - cipher/sha512-ssse3-amd64.S #+begin_quote Copyright (c) 2012, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    [Show full text]