Download in a Separate Pdf File

Total Page:16

File Type:pdf, Size:1020Kb

Download in a Separate Pdf File Note: Appendices are available for download in a separate pdf file. But we NEED to BE developers! DBAs frequently (constantly?) get called on to develop “quick” database scripts and programs, never mind that we don‟t have the time, the tools, or the training. From a quick, little runstats script in ksh, to a full blown application to load data or “fix a few rows”, it seems that if the data is in the database, it‟s my job to fix it! This presentation will present examples of manipulating DB2 data in several programming languages commonly used with DB2 LUW ( ksh, perl/dbi, SQL/PL, java/jdbc ) and discuss the plusses and minuses of each. Heavy emphasis will be placed on error handling, as this is one of areas that is most often overlooked or under developed. My favorite utility will be explained and sample code in perl and java will be discussed. 1 Next, I will share some of my favorite utilities, tools, tips and tricks to help the DBA get things done. 1 Show similar common DBA tasks in different languages, and give you some “tips and tricks” for each. Number 1 Depends on your DBA job description. But, for some of us… It is a novel idea that needs to be evangelized. 2 As a DBA, we are constantly tasked with fixing data, loading tables, and running utilities. It seems like, “If it lives in a database table, It‟s our responsibility to load, correct, and maintain.” We need to have and use the proper tools to do this. Many developers with LOTS of tools. One DBA, with…. Ksh and CLP. 3 This is the proper attitude for us to have. As long as we have a great set of tools to work with! However, UNLIKE Jeff Spicoli, we need to actually HAVE good tools and know how to use them. 4 Show similar common DBA task in three different languages, and give you some “tips and tricks” for each. Favorite bumper sticker – Think Geek used to sell them. Woodshop analogy: • If I want to help you get into woodworking: • Show you some cool tools: • Miter saw • Band saw • Planer • Jointer • All “cut” wood. All very cool. All useful. • Good in different ways and in different cases • Show you a cool “Chest of drawers” that you can build with it • That is what I am going to do with software tools 5 Show similar common DBA task in different languages, and give you some “tips and tricks” for each. Many times we are going into a fight with no weapons. (Or at least the wrong ones. ) Others? Python XML 6 Some good Manuals from the DB2 documents. http://www-01.ibm.com/support/docview.wss?uid=swg27038855 7 Note: Typeset –u – uppercase dbname ${1-sample} – default value for a parameter Backticks ` ` to run a command and capture it‟s output We are running db2 commands via the clp Five GLARING errors or Issues with this script: 1) No error checking What if you don‟t get something good back from db2? What if connect fails? 2) No way to check return codes from “underneath” tee command 3) No return code on the exit 4) “race condition” exists on select vs delete. The time between them is >0, so they may get different row count as rows may get old enough to be purged. 5) NO Intermediate COMMITS!!!!! Will this blow up your logs? What if it doesn‟t run for a while, then gets run? This is hard to fix in ksh / clp 8 Note: Trying to handle the “race” condition by using start_ts (which is, The time at which I start purging rows) Use count as the Number of rows to delete Using an error handling function: sql_error_handler Part of my standard library simply a case statement on rc 0 – ok 1 – no rows found 4 – warning 8 - error 9 Note: Looping until we delete enough rows. Committing every “chunk_sz” rows Using variable output to capture sqlca info from “db2 –a” purge_row is: number of rows from sqlca sqlcode: from sqlca Issues: Must rerun query to determine deletable rows over and over – no cursor. This could be really expensive! 10 This is an example of what “db2 –a” output looks like, so that you can see what I am “cut”ting out. This is somewhat fragile, should DB2 change this output. Not prod ready IMHO… Not sufficiently advanced technology - I can tell it from Magic 11 DB2 CLP is limited by the SQLCA - 32K buffer size “Panel” at idug in philly had a suggestion (that I haven‟t gotten to work, yet) WLM_SET_CLIENT_INFO procedure Have been forced to do some work in “O-rackle” lately. I MISS the CLP… 12 Need: A library of tools / functions. 13 See Appendix A Use of function in ksh Comments! They are GOOD! Check to see if the log file exists. If not, see if I can touch the log file and if so, can I write to it.? If not, write out reasonable errors and die with a RC 1. 14 Note: If both stdout (1) and stderr (2) are a tty, then I must be on a terminal. Basically, I am sending stdout and stderr to the log file, or if I‟m a terminal, I send it to tee and push it to the tty and the log file. use of print – more POSIX compliant vs echo. 15 See Appendix A This just shuts down the file descriptors using exec and makes sure to wait for the children to actually return. Maybe it should check to see if the logging is actually started, before it tries to stop it… 16 Note: “Source” in our .profile – big deal if running from cron Cron environment VERY different from your login environment. None of YOUR “stuff” .profile, .login pulled in. Cron environment is a “crippled” environment. Pull in our function library. Use of basename to get program name Fully qualified program names – good practice especially if running from cron ($PATH may not be your $PATH) Function call: Call to start_logging – passes in a log file name (This is verified in the function) stop_logging – no parameters Reading input from a file on a specific file descriptor – not commonly done in ksh. In this program, I also read from the terminal, so I need to use a separate “fd” for this input file. Continue statement { } – use – delimiter – reduces ambiguity – BEST practice! LOGFILE=${RECIPEFILE%.*}.log - strips anything to the right of the first „.‟ 17 Note: Good to have a heading with common stuff in it. Options for ksh: xtrace (-x) - debug nounset – will die if you don‟t have a param set errexit - can make error handling easier 18 Note: Co-worker who did this trick all the time. I had never seen it. Concern: What if you don‟t get exactly what you expect, when you read? Can you catch all possible weirdness??? - Buffer overflows, and SQL injections in this kind of thing, are very possible. 19 Note: Co-worker who did this trick all the time. I had never seen it. Concern: What if you don‟t get exactly what you expect, when you read? Can you catch all possible weirdness??? - Buffer overflows, and SQL injections in this kind of thing, are very possible. 20 From my backup script: All this just to subtract one from the log file name! Could do MUCH more easily in perl. 21 See Appendix B So, let‟s move on to Stored Procedures. 22 See Appendix B 23 Documentation implies that you have to do ENABLE to get the Output buffer to work. I Never have before. However, this time, I wrote more than the default 20,000 bytes and the proc would die with a SQL20511N. Yikes! This ENABLE Proc makes it “work”, but IMHO, it is still very fragile, if I log a bit too much, my proc will break. 24 25 26 27 He contends that this is much more efficient than the previous cursor based Stored proc. Serge knows more about SQL and the optimizer than I. I believe that it IS faster than the cursor version. But I notice that it does do the select multiple times. Which can be bad if the select is expensive. There are many variables, such as how expensive the select is, how the cursor is handled, i.e.: how many rows are buffered on each fetch, etc. 28 29 30 Here is a way to solve the “wrap a variable in single quotes but still let the shell inside the quotes to evaluate the variable” issue. I used a here document. (which adds a gratuitous newline). I used tr to chop the new line off. 31 When I started this presentation, I thought that I could create this little wrapper script quickly. I spent hours getting this „single quote‟ issue resolved. Still doesn‟t work in ksh/Cygwin on windows. ??? Anyone?? - superceded… Note: Solved!!!! TRIMMED_TS=`echo ${QUOTED_TS} | tr -d '\n‘ | tr –d ‘\r’` windows newline. I have never, BTW, gotten the perl/dbi working against db2 on Cygwin. Anyone? 32 The DBI is a library that provides database routines that are agnostic about the underlying database. The various DBDs provide routines to support dbi calls for a given database manager. 33 The DBI is a library that provides database routines that are agnostic about the underlying database. The various DBDs provide routines to support dbi calls for a given database manager. May need to recompile perl for AIX to get performance enhancements, Multi- threading, etc.
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]
  • 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]
  • Modern Perl, Fourth Edition
    Prepared exclusively for none ofyourbusiness Prepared exclusively for none ofyourbusiness Early Praise for Modern Perl, Fourth Edition A dozen years ago I was sure I knew what Perl looked like: unreadable and obscure. chromatic showed me beautiful, structured expressive code then. He’s the right guy to teach Modern Perl. He was writing it before it existed. ➤ Daniel Steinberg President, DimSumThinking, Inc. A tour de force of idiomatic code, Modern Perl teaches you not just “how” but also “why.” ➤ David Farrell Editor, PerlTricks.com If I had to pick a single book to teach Perl 5, this is the one I’d choose. As I read it, I was reminded of the first time I read K&R. It will teach everything that one needs to know to write Perl 5 well. ➤ David Golden Member, Perl 5 Porters, Autopragmatic, LLC I’m about to teach a new hire Perl using the first edition of Modern Perl. I’d much rather use the updated copy! ➤ Belden Lyman Principal Software Engineer, MediaMath It’s not the Perl book you deserve. It’s the Perl book you need. ➤ Gizmo Mathboy Co-founder, Greater Lafayette Open Source Symposium (GLOSSY) Prepared exclusively for none ofyourbusiness We've left this page blank to make the page numbers the same in the electronic and paper books. We tried just leaving it out, but then people wrote us to ask about the missing pages. Anyway, Eddy the Gerbil wanted to say “hello.” Prepared exclusively for none ofyourbusiness Modern Perl, Fourth Edition chromatic The Pragmatic Bookshelf Dallas, Texas • Raleigh, North Carolina Prepared exclusively for none ofyourbusiness Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks.
    [Show full text]
  • Perl by Example, Third Edition—This Book Is a Superb, Well-Written Programming Book
    Praise for Ellie Quigley’s Books “I picked up a copy of JavaScript by Example over the weekend and wanted to thank you for putting out a book that makes JavaScript easy to understand. I’ve been a developer for several years now and JS has always been the ‘monster under the bed,’ so to speak. Your book has answered a lot of questions I’ve had about the inner workings of JS but was afraid to ask. Now all I need is a book that covers Ajax and Coldfusion. Thanks again for putting together an outstanding book.” —Chris Gomez, Web services manager, Zunch Worldwide, Inc. “I have been reading your UNIX® Shells by Example book, and I must say, it is brilliant. Most other books do not cover all the shells, and when you have to constantly work in an organization that uses tcsh, bash, and korn, it can become very difficult. However, your book has been indispensable to me in learning the various shells and the differences between them…so I thought I’d email you, just to let you know what a great job you have done!” —Farogh-Ahmed Usmani, B.Sc. (Honors), M.Sc., DIC, project consultant (Billing Solutions), Comverse “I have been learning Perl for about two months now; I have a little shell scripting experience but that is it. I first started withLearning Perl by O’Reilly. Good book but lacking on the examples. I then went to Programming Perl by Larry Wall, a great book for intermediate to advanced, didn’t help me much beginning Perl.
    [Show full text]
  • Programming Perl, 3Rd Edition
    Programming Perl Programming Perl Third Edition Larry Wall, Tom Christiansen & Jon Orwant Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo Programming Perl, Third Edition by Larry Wall, Tom Christiansen, and Jon Orwant Copyright © 2000, 1996, 1991 O’Reilly & Associates, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472. Editor, First Edition: Tim O’Reilly Editor, Second Edition: Steve Talbott Editor, Third Edition: Linda Mui Technical Editor: Nathan Torkington Production Editor: Melanie Wang Cover Designer: Edie Freedman Printing History: January 1991: First Edition. September 1996: Second Edition. July 2000: Third Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly & Associates, 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 & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. The association between the image of a camel and the Perl language is a trademark of O’Reilly & Associates, Inc. Permission may be granted for non-commercial use; please inquire by sending mail to [email protected]. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. Library of Congress Cataloging-in-Publication Data Wall, Larry. Programming Perl/Larry Wall, Tom Christiansen & Jon Orwant.--3rd ed. p. cm. ISBN 0-596-00027-8 1.
    [Show full text]
  • Ruby Language
    Ruby Language #ruby Table of Contents About 1 Chapter 1: Getting started with Ruby Language 2 Remarks 2 Versions 2 Examples 2 Hello World from IRB 2 Hello World with tk 3 Example code: 3 Hello World 4 Hello World without source files 4 Hello World as a Self-Executable File—using Shebang (Unix-like operating systems only) 4 My First Method 5 Overview 5 Explanation 5 Chapter 2: Arrays 6 Syntax 6 Examples 6 #map 6 Creating an Array with the literal constructor [ ] 6 Create Array of Strings 7 Create Array of Symbols 7 Create Array with Array::new 7 Manipulating Array Elements 8 Arrays union, intersection and difference 9 Filtering arrays 10 Select 10 Reject 10 Inject, reduce 10 Accessing elements 11 Two-dimensional array 12 Arrays and the splat (*) operator 12 Decomposition 13 Turn multi-dimensional array into a one-dimensional (flattened) array 15 Get unique array elements 15 Get all combinations / permutations of an array 15 Create an Array of consecutive numbers or letters 16 Remove all nil elements from an array with #compact 17 Create Array of numbers 17 Cast to Array from any object 18 Chapter 3: Blocks and Procs and Lambdas 20 Syntax 20 Remarks 20 Examples 20 Proc 20 Lambdas 21 Objects as block arguments to methods 22 Blocks 22 Yielding 23 Variables 24 Converting to Proc 24 Partial Application and Currying 25 Currying and Partial Applications 26 More useful examples of currying 26 Chapter 4: C Extensions 28 Examples 28 Your first extension 28 Working with C Structs 29 Writing Inline C - RubyInLine 30 Chapter 5: Casting (type conversion)
    [Show full text]
  • Brochure to Find the Sessions That Meet Your Interests, Or Check out Pp
    April 10–15, 2005 Marriott Anaheim Anaheim, CA Join our community of programmers, developers, and systems professionals in sharing solutions and fresh ideas on topics including Linux, clusters, security, open source, system administration, and more. April 10–15, 2005 KEYNOTE ADDRESS by George Dyson, historian and author of Darwin Among the Machines Design Your Own Conference: Combine Tutorials, Invited Talks, Refereed Papers, and Guru Sessions to customize the conference just for you! 5-Day Training Program 3-Day Technical Program Choose one subject or mix and Evening events include: April 10–14 April 13–15, 4 Tracks match to meet your needs. • Poster and Demo Sessions • Now with half-day tutorials • General Session Themes include: • Birds-of-a-Feather Sessions • More than 35 to choose from Refereed Papers • Coding • Vendor BoFs • Learn from industry experts • FREENIX/Open Source • Networking • Receptions • Over 15 new tutorials Refereed Papers • Open Source • Invited Talks • Security • Guru Is In Sessions • Sys Admin Register by March 21 and save up to $300 • www.usenix.org/anaheim05 CONFERENCE AT A GLANCE Sunday, April 10, 2005 7:30 a.m.–5:00 p.m. ON-SITE REGISTRATION 9:00 a.m.–5:00 p.m. TRAINING PROGRAM 6:00 p.m.–7:00 p.m. WELCOME RECEPTION 6:30 p.m.–7:00 p.m. CONFERENCE ORIENTATION Monday, April 11, 2005 7:30 a.m.–5:00 p.m. ON-SITE REGISTRATION 9:00 a.m.–5:00 p.m. TRAINING PROGRAM 8:30 p.m.–11:30 p.m. BIRDS-OF-A-FEATHER SESSIONS CONTENTS INVITATION FROM THE PROGRAM CHAIRS 1 Tuesday, April 12, 2005 7:30 a.m.–5:00 p.m.
    [Show full text]
  • Beginning Perl
    Beginning Perl Simon Cozens With Peter Wainwright Wrox Press Ltd. Beginning Perl © 2000 Wrox Press All rights reserved. No part of this book may be reproduced, stored in a retrieval system or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical articles or reviews. The authors and publisher have made every effort in the preparation of this book to ensure the accuracy of the information. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, Wrox Press nor its dealers or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. First Published June 2000 Published by Wrox Press Ltd Arden House, 1102 Warwick Road, Acock's Green, Birmingham B27 6BH, UK Printed in USA ISBN 1-861003-14-5 Trademark Acknowledgements Wrox has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Wrox cannot guarantee the accuracy of this information. Credits Author Category Manager Simon Cozens Viv Emery Contributing Authors Author Agent Peter Wainwright Rob Miller Additional Material Proofreader Joshua Schachter Carol Pinchefsky Technical Architect Production Manager Daniel Maharry Laurent Lafon Technical Editors Project Administrators Dan Squier Marsha Collins David Mercer Nicola Phillips Technical Reviewers Production Coordinator Matt Busigin Mark Burdett Yoz Grahame Jerry Heyman Ilustrations David Hudson William Fallon Matthew Kirkwood Nick Perry Cover Will Powell Shelley Frazier Kirrily Roberts Adam Turoff Index Bruce Varney Martin Brooks Paul Warren About the Authors Simon Cozens Simon Cozens has been programming PCs as a freelance contractor since the age of 10.
    [Show full text]
  • Perl by Example, Third Edition—This Book Is a Superb, Well-Written Programming Book
    Praise for Ellie Quigley’s Books “I picked up a copy of JavaScript by Example over the weekend and wanted to thank you for putting out a book that makes JavaScript easy to understand. I’ve been a developer for several years now and JS has always been the ‘monster under the bed,’ so to speak. Your book has answered a lot of questions I’ve had about the inner workings of JS but was afraid to ask. Now all I need is a book that covers Ajax and Coldfusion. Thanks again for putting together an outstanding book.” —Chris Gomez, Web services manager, Zunch Worldwide, Inc. “I have been reading your UNIX® Shells by Example book, and I must say, it is brilliant. Most other books do not cover all the shells, and when you have to constantly work in an organization that uses tcsh, bash, and korn, it can become very difficult. However, your book has been indispensable to me in learning the various shells and the differences between them…so I thought I’d email you, just to let you know what a great job you have done!” —Farogh-Ahmed Usmani, B.Sc. (Honors), M.Sc., DIC, project consultant (Billing Solutions), Comverse “I have been learning Perl for about two months now; I have a little shell scripting experience but that is it. I first started withLearning Perl by O’Reilly. Good book but lacking on the examples. I then went to Programming Perl by Larry Wall, a great book for intermediate to advanced, didn’t help me much beginning Perl.
    [Show full text]
  • Parallelism for Racket
    PLACES: PARALLELISM FOR RACKET by Kevin B. Tew A dissertation submitted to the faculty of The University of Utah in partial fulfillment of the requirements for the degree of Doctor of Philosophy in Computer Science School of Computing The University of Utah August 2013 Copyright © Kevin B. Tew 2013 All Rights Reserved THE UNIVERSITY OF UTAH GRADUATE SCHOOL STATEMENT OF DISSERTATION APPROVAL The dissertation of Kevin B. Tew has been approved by the following supervisory committee members: Matthew Flatt, Chair March 17, 2013 Date Approved John Regehr, Member March 5, 2013 Date Approved Mary Hall, Member March 26, 2013 Date Approved Matthew Might, Member March 6, 2013 Date Approved Peter Dinda, Member Date Approved and by Alan Davis, Chair of the School of Computing and by Donna M. White, Interim Dean of The Graduate School ABSTRACT Places and distributed places bring new support for message-passing parallelism to Racket. This dissertation describes the programming model and how Racket’s sequential runtime-system was modified to support places and distributed places. The freedom to design the places programming model helped make the implementation tractable; specifically, the conventional pain of adding just the right amount of locking to a big, legacy runtime system was avoided. The dissertation presents an evaluation of the places design that includes both real-world applications and standard parallel benchmarks. Distributed places are introduced as a language extension of the places design and architecture. The distributed places extension augments places with the features of remote process launch, remote place invocation, and distributed message passing. Distributed places provide a foundation for constructing higher-level distributed frameworks.
    [Show full text]
  • Modern Perl for Biologists I | the Basics M-BIM / INBTBI
    Modern Perl for Biologists I | The Basics M-BIM / INBTBI Denis BAURAIN / ULiège Edition 2020–2021 Denis BAURAIN / ULiège ii Modern Perl for Biologists I | The Basics Acknowledgment This course has been developed over eight years (2013–2020) primarily as teaching materials for the Modern Perl module of the (INBTBI) Bioinformatics Training organized by the Biotechnology Training Centre in the GIGA Tower of the University of Liège (Belgium). Until 2016, the Biotechnology Training Centre was directed by Laurent Corbesier, who is warmly thanked for his support. The training itself was funded through the Bioinformatics Training Program, 6th call 2010–2014, BioWin (the Health Cluster of Wallonia), Le Forem (the Walloon Office for Employment and Training), and the Biotechnology Training Centre (Forem-GIGA). This two-part document benefitted from the feed-back of about 150 students, trainees and colleagues, among which Arnaud Di Franco, Agnieszka Misztak, Loïc Meunier and Sinaeda Anderssen are espe- cially acknowledged. If you spot typos, grammatical or technical errors, or have any suggestion on how to improve the next edition of this course, let me know ([email protected]). I will answer all messages. Finally, I thank Pierre (Pit) Tocquin for his help with the mighty triad Markdown / Pandoc / LATEX. How to read this course? This document is written in American English. The first time they are introduced, programming terms and biological terms are typeset in bold and italic, respectively, whereas computer keywords are always typeset in a monospaced font (Consolas). All these terms are indexed at most once per section in which they appear (see Index).
    [Show full text]
  • Files and Data
    Files and Data We're starting to write real programs now, and real programs need to be able to read and write files to and from your hard drive. At the moment, all we can do is ask the user for input using <STDIN> and print data on the screen using print. Pretty simple stuff, yes, but these two ideas actually form the basis of a great deal of the file handling you'll be doing in Perl. What we want to do in this chapter is extend these techniques into reading from and writing to files, and we'll also look at the other techniques we have for handling files, directories, and data. Filehandles First though, let's do some groundwork. When we're dealing with files, we need something that tells Perl which file we're talking about, which allows us to refer to and access a certain file on the disk. We need a label, something that will give us a 'handle' on the file we want to work on. For this reason, the 'something' we want is known as a filehandle. We've actually already seen a filehandle: the STDIN of <STDIN>. This is a filehandle for the special file 'standard input', and whenever we've used the idiom <STDIN> to read a line, we've been reading from the standard input file. Standard input is the input provided by a user either directly as we've seen, by typing on the keyboard, or indirectly, through the use of a 'pipe' that (as we'll see) pumps input into the program.
    [Show full text]