Modern Perl for Biologists II | Deeper Concepts M-BIM / INBTBI

Total Page:16

File Type:pdf, Size:1020Kb

Modern Perl for Biologists II | Deeper Concepts M-BIM / INBTBI Modern Perl for Biologists II | Deeper Concepts M-BIM / INBTBI Denis BAURAIN / ULiège Edition 2020–2021 Denis BAURAIN / ULiège ii Modern Perl for Biologists II | Deeper Concepts 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). While the main text is typeset in Palatino, user statements (either at the shell or as small code excerpts) and computer answers are typeset in the same monospaced font as computer keywords. $ echo "Hello world!" # user statement (note the shell prompt) Hello world! # computer answer Example BOX Advanced material that can be skipped on first reading is enclosed in boxes with a light blue background. A List of Boxes is available for convenience. General programming advices and good practices that apply beyond the Perl language are typeset in a smaller size and introduced by a yellow bar surmounted by an icon. 1 say <<'EOT'; 2 Complete program listings are typeset 3 in the same monospaced font as keywords. 4 Their lines are numbered. 5 EOT Denis BAURAIN / ULiège iii Modern Perl for Biologists II | Deeper Concepts Denis BAURAIN / ULiège iv Modern Perl for Biologists II | Deeper Concepts Contents Acknowledgment ......................................... iii How to read this course? ..................................... iii I Lesson 6 1 1 Thinking in list context 3 1.1 Old-school plots in the terminal .............................. 3 1.2 Perl values: Lists ...................................... 7 1.3 Storing lists in arrays .................................... 12 1.4 Storing lists in hashes .................................... 16 1.5 Working with lists ...................................... 17 2 Formatting output 21 2.1 check_overlap.pl output sample ............................. 21 2.2 How to round numbers? .................................. 21 2.2.1 floor and ceil ................................... 22 2.2.2 sprintf ....................................... 22 2.3 The repetition operator ................................... 23 2.4 More on Smart::Comments ................................. 25 3 Functions 27 3.1 What are functions? ..................................... 27 3.2 Defining and using functions ................................ 27 3.3 Function parameters and return values .......................... 29 3.3.1 The default array @_ ................................ 29 3.3.2 return ........................................ 29 3.3.3 Argument aliasing ................................. 29 3.3.4 Lexical and file variables .............................. 31 3.3.5 Argument slurping ................................. 31 3.3.6 Argument currying ................................. 31 3.3.7 Bare return statements ............................... 33 3.3.8 Argument flattening ................................ 33 3.4 Bonus—Computing anagrams using recursive function calls . 35 Homework 39 Denis BAURAIN / ULiège v Modern Perl for Biologists II | Deeper Concepts CONTENTS II Lesson 7 41 4 Sorted codon usage 43 4.1 A gentle introduction to references ............................. 43 4.1.1 Motivation ..................................... 43 4.1.2 Defining references ................................. 45 4.1.3 Using references .................................. 46 4.1.4 Anonymous arrays ................................. 46 4.1.5 Peeking into nested data structures ........................ 48 4.2 Sorting tables ........................................ 49 4.2.1 sort ......................................... 49 4.2.2 Sort blocks and sort comparison operators .................... 49 4.2.3 Sorting contexts ................................... 50 4.2.4 The dereferencing arrow .............................. 52 4.2.5 Short-circuiting and multiple sorting criteria ................... 53 5 In silico restriction mapping 55 5.1 Your very personal cutter .................................. 55 5.1.1 How to build an enzyme database? ........................ 55 5.1.2 How to fetch sequences from the NCBI website? . 56 5.1.3 How to try the program? .............................. 56 5.2 The code for cutter.pl .................................. 57 Homework 67 III Lesson 8 69 6 The innards of cutter.pl 71 6.1 Plain Old Documentation .................................. 71 6.2 Getopt::Euclid ...................................... 74 6.3 Overview of cutter.pl .................................. 75 6.3.1 Command-line interface .............................. 75 6.3.2 Architecture ..................................... 77 6.4 More on references ..................................... 80 6.4.1 Tabular file parsing ................................. 82 6.4.1.1 read_enzymes .............................. 82 6.4.2 Defining and using nested data structures .................... 84 6.4.2.1 compute_cuts .............................. 84 6.4.2.2 collect_sites .............................. 87 6.4.2.3 infer_fragments ............................ 88 7 Parsing BLAST reports 93 7.1 BLAST tabular format .................................... 93 7.2 How to write a Perl module? ................................ 94 7.2.1 The code for blast_table.t ............................ 95 7.2.2 The code for parser.pl .............................. 96 7.2.3 The code for BlastTable.pm ............................ 97 Homework 101 Denis BAURAIN / ULiège vi Modern Perl for Biologists II | Deeper Concepts CONTENTS IV Lesson 9 103 8 More on Perl modules 105 8.1 Structure of a Perl distribution ............................... 105 8.2 Installing Perl modules ................................... 106 8.2.1 Fine-tuning the installation process . 107 8.2.2 Specifying module dependencies . 107 8.3 Anatomy of a Perl module ................................. 110 8.3.1 packages and namespaces ............................. 110 8.3.2 Exporting symbols ................................. 112 8.4 Automated tests ....................................... 113 9 Our ultimate killer app 115 9.1 Annotating sequences with reference sequences ..................... 115 9.2 Packaging read_fasta and friends ............................ 115 9.2.1 The code for fasta_file.t ............................ 117 9.2.2 The code for FastaFile.pm ............................ 118 9.3 Building our application .................................. 123 9.3.1 The code for annotate.pl ............................. 123 Homework 129 V Lesson 10 131 10 Idiomatic Perl 133 10.1 More on closures ...................................... 133 10.1.1 Function references ................................. 133 10.1.2 subs with a memory ................................ 134 10.2 The default variables .................................... 137 10.2.1 The topic variable as the default iterator . 138 10.3 Implicit loops ........................................ 140 10.3.1 grep ......................................... 140 10.3.2 map .......................................... 142 10.4 Bonus—Higher-Order Perl ................................. 146 11 Dissecting our annotation app 151 11.1 More on automated tests .................................. 151 11.2 Interesting bits in Forem::FastaFile . 152 11.3 A mighty modular script: annotate.pl . 154 11.3.1 Conciseness, readability and maintainability by code reuse . 154 11.3.2 Building programs with programs . 156 11.3.3 Calling external programs ............................. 158 11.3.4 Wrapping it up ................................... 159 Homework 161 Index 163 Denis BAURAIN / ULiège vii Modern Perl for Biologists II | Deeper Concepts CONTENTS Denis BAURAIN / ULiège viii Modern Perl for Biologists II | Deeper Concepts List of Boxes 1 Operator precedence in list definitions ............................. 10 2 Array slices and the amount context ............................... 14 3 Accessing individual values in lists ............................... 15 4 Reference count and the garbage collector ........................... 47 5 Sorting in natural order ...................................... 51 6 Short-circuiting and assignments ................................ 54 7 Named arguments ........................................ 76 8 Closures and BEGIN code blocks ................................ 79 9 Scalar references
Recommended publications
  • Glibc and System Calls Documentation Release 1.0
    Glibc and System Calls Documentation Release 1.0 Rishi Agrawal <[email protected]> Dec 28, 2017 Contents 1 Introduction 1 1.1 Acknowledgements...........................................1 2 Basics of a Linux System 3 2.1 Introduction...............................................3 2.2 Programs and Compilation........................................3 2.3 Libraries.................................................7 2.4 System Calls...............................................7 2.5 Kernel.................................................. 10 2.6 Conclusion................................................ 10 2.7 References................................................ 11 3 Working with glibc 13 3.1 Introduction............................................... 13 3.2 Why this chapter............................................. 13 3.3 What is glibc .............................................. 13 3.4 Download and extract glibc ...................................... 14 3.5 Walkthrough glibc ........................................... 14 3.6 Reading some functions of glibc ................................... 17 3.7 Compiling and installing glibc .................................... 18 3.8 Using new glibc ............................................ 21 3.9 Conclusion................................................ 23 4 System Calls On x86_64 from User Space 25 4.1 Setting Up Arguements......................................... 25 4.2 Calling the System Call......................................... 27 4.3 Retrieving the Return Value......................................
    [Show full text]
  • Chapter 4 Programming in Perl
    Chapter 4 Programming in Perl 4.1 More on built-in functions in Perl There are many built-in functions in Perl, and even more are available as modules (see section 4.4) that can be downloaded from various Internet places. Some built-in functions have already been used in chapter 3.1 and some of these and some others will be described in more detail here. 4.1.1 split and join (+ qw, x operator, \here docs", .=) 1 #!/usr/bin/perl 2 3 $sequence = ">|SP:Q62671|RATTUS NORVEGICUS|"; 4 5 @parts = split '\|', $sequence; 6 for ( $i = 0; $i < @parts; $i++ ) { 7 print "Substring $i: $parts[$i]\n"; 8 } • split is used to split a string into an array of substrings. The program above will write out Substring 0: > Substring 1: SP:Q62671 Substring 2: RATTUS NORVEGICUS • The first argument of split specifies a regular expression, while the second is the string to be split. • The string is scanned for occurrences of the regexp which are taken to be the boundaries between the sub-strings. 57 58 CHAPTER 4. PROGRAMMING IN PERL • The parts of the string which are matched with the regexp are not included in the substrings. • Also empty substrings are extracted. Note, however that trailing empty strings are removed by default. • Note that the | character needs to be escaped in the example above, since it is a special character in a regexp. • split returns an array and since an array can be assigned to a list we can write: splitfasta.ply 1 #!/usr/bin/perl 2 3 $sequence=">|SP:Q62671|RATTUS NORVEGICUS|"; 4 5 ($marker, $code, $species) = split '\|', $sequence; 6 ($dummy, $acc) = split ':', $code; 7 print "This FastA sequence comes from the species $species\n"; 8 print "and has accession number $acc.\n"; splitfasta.ply • It is not uncommon that we want to write out long pieces of text using many print statements.
    [Show full text]
  • The Clon User Manual the Command-Line Options Nuker, Version 1.0 Beta 25 "Michael Brecker"
    The Clon User Manual The Command-Line Options Nuker, Version 1.0 beta 25 "Michael Brecker" Didier Verna <[email protected]> Copyright c 2010{2012, 2015, 2017, 2020, 2021 Didier Verna Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the section entitled \Copy- ing" is included exactly as in the original. Permission is granted to copy and distribute translations of this manual into an- other language, under the above conditions for modified versions, except that this permission notice may be translated as well. Cover art by Alexis Angelidis. i Table of Contents Copying ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1 1 Introduction :::::::::::::::::::::::::::::::::::::::::::::::::::: 3 2 Installation:::::::::::::::::::::::::::::::::::::::::::::::::::::: 5 3 Quick Start ::::::::::::::::::::::::::::::::::::::::::::::::::::: 7 3.1 Full Source :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 7 3.2 Explanation ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 7 4 Using Clon :::::::::::::::::::::::::::::::::::::::::::::::::::: 11 4.1 Synopsis Definition ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 4.1.1 Synopsis Items ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 11 4.1.1.1 Text ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    [Show full text]
  • Using the GNU Compiler Collection (GCC)
    Using the GNU Compiler Collection (GCC) Using the GNU Compiler Collection by Richard M. Stallman and the GCC Developer Community Last updated 23 May 2004 for GCC 3.4.6 For GCC Version 3.4.6 Published by: GNU Press Website: www.gnupress.org a division of the General: [email protected] Free Software Foundation Orders: [email protected] 59 Temple Place Suite 330 Tel 617-542-5942 Boston, MA 02111-1307 USA Fax 617-542-2652 Last printed October 2003 for GCC 3.3.1. Printed copies are available for $45 each. Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being \GNU General Public License" and \Funding Free Software", the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled \GNU Free Documentation License". (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ...................................... 1 1 Programming Languages Supported by GCC ............ 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .........................
    [Show full text]
  • [PDF] Beginning Raku
    Beginning Raku Arne Sommer Version 1.00, 22.12.2019 Table of Contents Introduction. 1 The Little Print . 1 Reading Tips . 2 Content . 3 1. About Raku. 5 1.1. Rakudo. 5 1.2. Running Raku in the browser . 6 1.3. REPL. 6 1.4. One Liners . 8 1.5. Running Programs . 9 1.6. Error messages . 9 1.7. use v6. 10 1.8. Documentation . 10 1.9. More Information. 13 1.10. Speed . 13 2. Variables, Operators, Values and Procedures. 15 2.1. Output with say and print . 15 2.2. Variables . 15 2.3. Comments. 17 2.4. Non-destructive operators . 18 2.5. Numerical Operators . 19 2.6. Operator Precedence . 20 2.7. Values . 22 2.8. Variable Names . 24 2.9. constant. 26 2.10. Sigilless variables . 26 2.11. True and False. 27 2.12. // . 29 3. The Type System. 31 3.1. Strong Typing . 31 3.2. ^mro (Method Resolution Order) . 33 3.3. Everything is an Object . 34 3.4. Special Values . 36 3.5. :D (Defined Adverb) . 38 3.6. Type Conversion . 39 3.7. Comparison Operators . 42 4. Control Flow . 47 4.1. Blocks. 47 4.2. Ranges (A Short Introduction). 47 4.3. loop . 48 4.4. for . 49 4.5. Infinite Loops. 53 4.6. while . 53 4.7. until . 54 4.8. repeat while . 55 4.9. repeat until. 55 4.10. Loop Summary . 56 4.11. if . ..
    [Show full text]
  • Memory Tagging and How It Improves C/C++ Memory Safety Kostya Serebryany, Evgenii Stepanov, Aleksey Shlyapnikov, Vlad Tsyrklevich, Dmitry Vyukov Google February 2018
    Memory Tagging and how it improves C/C++ memory safety Kostya Serebryany, Evgenii Stepanov, Aleksey Shlyapnikov, Vlad Tsyrklevich, Dmitry Vyukov Google February 2018 Introduction 2 Memory Safety in C/C++ 2 AddressSanitizer 2 Memory Tagging 3 SPARC ADI 4 AArch64 HWASAN 4 Compiler And Run-time Support 5 Overhead 5 RAM 5 CPU 6 Code Size 8 Usage Modes 8 Testing 9 Always-on Bug Detection In Production 9 Sampling In Production 10 Security Hardening 11 Strengths 11 Weaknesses 12 Legacy Code 12 Kernel 12 Uninitialized Memory 13 Possible Improvements 13 Precision Of Buffer Overflow Detection 13 Probability Of Bug Detection 14 Conclusion 14 Introduction Memory safety in C and C++ remains largely unresolved. A technique usually called “memory tagging” may dramatically improve the situation if implemented in hardware with reasonable overhead. This paper describes two existing implementations of memory tagging: one is the full hardware implementation in SPARC; the other is a partially hardware-assisted compiler-based tool for AArch64. We describe the basic idea, evaluate the two implementations, and explain how they improve memory safety. This paper is intended to initiate a wider discussion of memory tagging and to motivate the CPU and OS vendors to add support for it in the near future. Memory Safety in C/C++ C and C++ are well known for their performance and flexibility, but perhaps even more for their extreme memory unsafety. This year we are celebrating the 30th anniversary of the Morris Worm, one of the first known exploitations of a memory safety bug, and the problem is still not solved.
    [Show full text]
  • Bbedit 13.5 User Manual
    User Manual BBEdit™ Professional Code and Text Editor for the Macintosh Bare Bones Software, Inc. ™ BBEdit 13.5 Product Design Jim Correia, Rich Siegel, Steve Kalkwarf, Patrick Woolsey Product Engineering Jim Correia, Seth Dillingham, Matt Henderson, Jon Hueras, Steve Kalkwarf, Rich Siegel, Steve Sisak Engineers Emeritus Chris Borton, Tom Emerson, Pete Gontier, Jamie McCarthy, John Norstad, Jon Pugh, Mark Romano, Eric Slosser, Rob Vaterlaus Documentation Fritz Anderson, Philip Borenstein, Stephen Chernicoff, John Gruber, Jeff Mattson, Jerry Kindall, Caroline Rose, Allan Rouselle, Rich Siegel, Vicky Wong, Patrick Woolsey Additional Engineering Polaschek Computing Icon Design Bryan Bell Factory Color Schemes Luke Andrews Additional Color Schemes Toothpaste by Cat Noon, and Xcode Dark by Andrew Carter. Used by permission. Additional Icons By icons8. Used under license Additional Artwork By Jonathan Hunt PHP keyword lists Contributed by Ted Stresen-Reuter. Previous versions by Carsten Blüm Published by: Bare Bones Software, Inc. 73 Princeton Street, Suite 206 North Chelmsford, MA 01863 USA (978) 251-0500 main (978) 251-0525 fax https://www.barebones.com/ Sales & customer service: [email protected] Technical support: [email protected] BBEdit and the BBEdit User Manual are copyright ©1992-2020 Bare Bones Software, Inc. All rights reserved. Produced/published in USA. Copyrights, Licenses & Trademarks cmark ©2014 by John MacFarlane. Used under license; part of the CommonMark project LibNcFTP Used under license from and copyright © 1996-2010 Mike Gleason & NcFTP Software Exuberant ctags ©1996-2004 Darren Hiebert (source code here) PCRE2 Library Written by Philip Hazel and Zoltán Herczeg ©1997-2018 University of Cambridge, England Info-ZIP Library ©1990-2009 Info-ZIP.
    [Show full text]
  • Intermediate Perl – Session 7
    1.1.2.8 – Intermediate Perl 1.1.2.8.7 Intermediate Perl – Session 7 · POD – plain old documentation · processing command line parameters · processing configuration files 9/23/2008 1.1.2.8.7 - Intermediate Perl - POD, parameters and configuration 1 1.1.2.8 – Intermediate Perl POD – plain old documentation ·embed documentation in your scripts with POD ·POD is very simple because it stands for Plain Old Documentation · it is meant to be easy to use – and it is! · POD is a simple markup language · write documentation once and export it to multiple formats · man, html, text · POD formatting codes are embedded in your script ·Pod::Usage module displays documentation for the script when the script is executed · how handy is that? 9/23/2008 1.1.2.8.7 - Intermediate Perl - POD, parameters and configuration 2 1.1.2.8 – Intermediate Perl POD structure – sections start and end pod with =pod =pod and =cut =head1 NAME script – take over the world in one line of Perl separate paragraphs by =head1 SYNOPSIS new lines script –mode EVIL|GOOD [-debug] use =head1 and =head2 =head1 DESCRIPTION for headings You can take over the world as an EVIL doer or a GOOD doer. Pick one. =head2 EVIL indent code Evil is more fun. =head2 GOOD =over and =back to =over indent text =item * advantages =item * for bullet lists none =item * disadvantages no fun =back =cut 9/23/2008 1.1.2.8.7 - Intermediate Perl - POD, parameters and configuration 3 1.1.2.8 – Intermediate Perl POD structure – ordinary paragraphs ordinary paragraphs # contents of podexample =pod representing text that =head1 EXAMPLE you'd like wrapped and justified have no This is an ordinary paragraph that will be indented, wrapped and maybe even justified.
    [Show full text]
  • Statically Detecting Likely Buffer Overflow Vulnerabilities
    Statically Detecting Likely Buffer Overflow Vulnerabilities David Larochelle [email protected] University of Virginia, Department of Computer Science David Evans [email protected] University of Virginia, Department of Computer Science Abstract Buffer overflow attacks may be today’s single most important security threat. This paper presents a new approach to mitigating buffer overflow vulnerabilities by detecting likely vulnerabilities through an analysis of the program source code. Our approach exploits information provided in semantic comments and uses lightweight and efficient static analyses. This paper describes an implementation of our approach that extends the LCLint annotation-assisted static checking tool. Our tool is as fast as a compiler and nearly as easy to use. We present experience using our approach to detect buffer overflow vulnerabilities in two security-sensitive programs. 1. Introduction ed a prototype tool that does this by extending LCLint [Evans96]. Our work differs from other work on static detection of buffer overflows in three key ways: (1) we Buffer overflow attacks are an important and persistent exploit semantic comments added to source code to security problem. Buffer overflows account for enable local checking of interprocedural properties; (2) approximately half of all security vulnerabilities we focus on lightweight static checking techniques that [CWPBW00, WFBA00]. Richard Pethia of CERT have good performance and scalability characteristics, identified buffer overflow attacks as the single most im- but sacrifice soundness and completeness; and (3) we portant security problem at a recent software introduce loop heuristics, a simple approach for engineering conference [Pethia00]; Brian Snow of the efficiently analyzing many loops found in typical NSA predicted that buffer overflow attacks would still programs.
    [Show full text]
  • 16.5. Getopt — Parser for Command Line Options — Python V2.6.4
    Navigation • index • modules | • next | • previous | • Python v2.6.4 documentation » • The Python Standard Library » • 16. Generic Operating System Services » 16.5. getopt — Parser for command line options¶ This module helps scripts to parse the command line arguments in sys.argv. It supports the same conventions as the Unix getopt() function (including the special meanings of arguments of the form ‘-‘ and ‘--‘). Long options similar to those supported by GNU software may be used as well via an optional third argument. A more convenient, flexible, and powerful alternative is the optparse module. This module provides two functions and an exception: getopt.getopt(args, options[, long_options])¶ Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means sys.argv[1:]. options is the string of option letters that the script wants to recognize, with options that require an argument followed by a colon (':'; i.e., the same format that Unix getopt() uses). Note Unlike GNU getopt(), after a non-option argument, all further arguments are considered also non-options. This is similar to the way non-GNU Unix systems work. long_options, if specified, must be a list of strings with the names of the long options which should be supported. The leading '--' characters should not be included in the option name. Long options which require an argument should be followed by an equal sign ('='). Optional arguments are not supported. To accept only long options, options should be an empty string. Long options on the command line can be recognized so long as they provide a prefix of the option name that matches exactly one of the accepted options.
    [Show full text]
  • Shell Script Getopts Example
    Shell Script Getopts Example Gail is constrainedly cryoscopic after delegable Hilbert sag his parcloses illuminatingly. Gonzales often tootle irresistibly when tripersonal Giordano discomposed dissonantly and buffer her Barbarossa. Robert misdraws rompishly. Find that getopts script example we use later will contain whitespace separation with command Instantly share code, notes, and snippets. OPTARG is set to the period character found. They cease in many cases unneeded and brief fact that cartoon always press them its just like matter of personal coding style. File or directory or found. Operator precedence is used when there within five is more arguments. Typically, shell scripts use getopts to parse arguments passed to them. There did many ways to against your remedy environment. Nothing gets printed when no command line options are provided. The return status is zero unless an outcome is encountered while determining the name avid the he directory within an invalid option is supplied. The exit code will be success failure. Log in charge use details from one require these accounts. How does log lumber and cpu usage by an application? Now consider running it bore an unsupported option. No need only pass the positional parameters through to borrow external program. How can I check took a directory exists in a candy shell script? What extent its purpose? When optional, the fashion can buckle on led off additional functionality, as ugly a boolean option. In those cases, it contains a pointer to that parameter. How environment check ride a variable is set to Bash? Connect and deploy knowledge write a single location that is structured and fatigue to search.
    [Show full text]
  • "This Book Was a Joy to Read. It Covered All Sorts of Techniques for Debugging, Including 'Defensive' Paradigms That Will Eliminate Bugs in the First Place
    Perl Debugged By Peter Scott, Ed Wright Publisher : Addison Wesley Pub Date : March 01, 2001 ISBN : 0-201-70054-9 Table of • Pages : 288 Contents "This book was a joy to read. It covered all sorts of techniques for debugging, including 'defensive' paradigms that will eliminate bugs in the first place. As coach of the USA Programming Team, I find the most difficult thing to teach is debugging. This is the first text I've even heard of that attacks the problem. It does a fine job. Please encourage these guys to write more." -Rob Kolstad Perl Debugged provides the expertise and solutions developers require for coding better, faster, and more reliably in Perl. Focusing on debugging, the most vexing aspect of programming in Perl, this example-rich reference and how-to guide minimizes development, troubleshooting, and maintenance time resulting in the creation of elegant and error-free Perl code. Designed for the novice to intermediate software developer, Perl Debugged will save the programmer time and frustration in debugging Perl programs. Based on the authors' extensive experience with the language, this book guides developers through the entire programming process, tackling the benefits, plights, and pitfalls of Perl programming. Beginning with a guided tour of the Perl documentation, the book progresses to debugging, testing, and performance issues, and also devotes a chapter to CGI programming in Perl. Throughout the book, the authors espouse defensible paradigms for improving the accuracy and performance of Perl code. In addition, Perl Debugged includes Scott and Wright's "Perls of Wisdom" which summarize key ideas from each of the chapters, and an appendix containing a comprehensive listing of Perl debugger commands.
    [Show full text]