Beginning Perl Scripting

Total Page:16

File Type:pdf, Size:1020Kb

Beginning Perl Scripting Beginning Perl Scripting Simple scripts, Expressions, Operators, Statements, Variables Simon Prochnik & Lincoln Stein Suggested Reading Learning Perl (6th ed.): Chap. 2, 3, 12, Unix & Perl to the Rescue (1st ed.): Chap. 4 Chapters 1, 2 & 5 of Learning Perl. Lecture Notes 1. What is Perl? 2. Some simple Perl scripts 3. Mechanics of creating a Perl script 4. Statements 5. Literals 6. Operators 7. Functions 8. Variables 9. Processing the Command Line Problems What is Perl? Perl is a Programming Language Written by Larry Wall in late 80's to process mail on Unix systems and since extended by a huge cast of characters. The name is said to stand for: 1. Pathologically Eclectic Rubbish Lister 2. Practical Extraction and Report Language Perl Properties 1. Interpreted Language 2. "Object-Oriented" 3. Cross-platform 4. Forgiving 5. Great for text 6. Extensible, rich set of libraries 7. Popular for web pages 8. Extremely popular for bioinformatics Other Languages Used in Bioinformatics 1 of 20 C, C++ Compiled languages, hence very fast. Used for computation (BLAST, FASTA, Phred, Phrap, ClustalW) Not very forgiving. Java Interpreted, fully object-oriented language. Built into web browsers. Supposed to be cross-platform, getting better. Python , Ruby Interpreted, fully object-oriented language. Rich set of libraries. Elegant syntax. Smaller user community than Java or Perl. Some Simple Scripts Here are some simple scripts to illustrate the "look" of a Perl program. Print a Message to the Terminal Code: #!/usr/bin/perl # file: message.pl use strict; use warnings; print "When that Aprill with his shoures soote\n"; print "The droghte of March ath perced to the roote,\n"; print "And bathed every veyne in swich licour\n"; print "Of which vertu engendered is the flour...\n"; Output: (~) 50% perl message.pl When that Aprill with his shoures soote The droghte of March ath perced to the roote, And bathed every veyne in swich licour Of which vertu engendered is the flour... Do Some Math Code: #!/usr/bin/perl # file: math.pl use strict; use warnings; print "2 + 2 =", 2+2, "\n"; print "log(1e23)= ", log(1e23), "\n"; print "2 * sin(3.1414)= ", 2 * sin(3.1414), "\n"; 2 of 20 Output: (~) 51% perl math.pl 2 + 2 =4 log(1e23)= 52.9594571388631 2 * sin(3.1414)= 0.000385307177203065 Run a System Command Code: #!/usr/bin/perl # file: system.pl use strict; use warnings; system "ls"; Output: (~/docs/grad_course/perl) 52% perl system.pl index.html math.pl~ problem_set.html~ what_is_perl.html index.html~ message.pl simple.html what_is_perl.html~ math.pl problem_set.html simple.html~ Return the Time of Day Code: #!/usr/bin/perl # file: time.pl use strict; use warnings; $time = localtime; print "The time is now $time\n"; Output: (~) 53% perl time.pl The time is now Thu Sep 16 17:30:02 1999 Mechanics of Writing Perl Scripts Some hints to help you get going. Creating the Script A Perl script is just a text file. Use any text (programmer's) editor. Don't use word processors like Word. By convention, Perl script files end with the extension .pl. 3 of 20 I suggest Emacs, because it is already installed on almost all Unix machines, but there are many good options: vi, vim, Textwrangler, eclipse The Emacs text editor has a Perl mode that will auto-format your Perl scripts and highlight keywords. Perl mode will be activated automatically if you end the script name with .pl. GUI-based script writing tools (Aquamacs, xemacs, Textwrangler, Eclipse) are easier to use, but you may have to install them yourself. Let's write a simple perl script. It'll be a simple text file called time.pl and will contain the lines above. Let's try doing this in emacs Emacs Essentials A GUI version is simpler to use e.g. Aquamacs, run it by adding the icon for the application to your Dock then clicking on the icon. You can also run emacs in a Terminal window. Emacs will be installed on almost every Unix system you encounter. (~) 50% emacs The same shortcuts you can use on the command line work in Emacs e.g. control-a (^a) move cursor to beginning of line etc The most important Emacs-specific commands control-x control-f (^x ^f) open a file control-x control-w (^x ^w) save as... control-x control-c (^x ^c) quit control-g (^g) cancel command shift-control-_ (^_) Undo typing control-h ?(^h ?) Help!! option-; (M;) Add comment option-/ (M/) Variable/subroutine name auto-completion (cycles through options) Running the Script Don't forget to save any changes in your script before running it. The filled red circle at the top left of the emacs GUI window has a dot in it if there are unsaved changes. Option 1 (quick, not used much) Run the perl program from the command line, giving it the name of the script file to run. (~) 50% perl time.pl The time is now Thu Sep 16 18:09:28 1999 4 of 20 Option 2 (as shown in examples above) Put the magic comment #!/usr/bin/perl at the top of your script. It's really easy to make a mistake with this complicated line and this causes confusing errors (see below). Double check, or copy from a friend who has it working. And always add use strict; use warnings; to the top of your script like in the example below #!/usr/bin/perl # file: time.pl use strict; use warnings; $time = localtime; print "The time is now $time\n"; Now make the script executable with chmod +x time.pl: (~) 51% chmod +x time.pl Run the script as if it were a command: (~) 52% ./time.pl The time is now Thu Sep 16 18:12:13 1999 Note that you have to type "./time.pl" rather than "time.pl" because, by default, bash does not search the current directory for commands to execute. To avoid this, you can add the current directory (".") to your search PATH environment variable. To do this, create a file in your home directory named .profile and enter the following line in it: export PATH=$PATH:. The next time you log in, your path will contain the current directory and you can type "time.pl" directly. Common Errors Plan out your script before you start coding. Write the code, then run it to see if it works. Every script goes through a few iterations before you get it right. Here are some common errors: Syntax Errors Code: 5 of 20 #!/usr/bin/perl # file: time.pl use strict; use warnings; time = localtime; print "The time is now $time\n"; Output: (~) 53% time.pl Can't modify time in scalar assignment at time.pl line 3, near "localtime;" Execution of time.pl aborted due to compilation errors. Runtime Errors Code: #!/usr/bin/perl # file: math.pl use strict; use warnings; $six_of_one = 6; $half_dozen = 12/2; $result = $six_of_one/($half_dozen - $six_of_one); print "The result is $result\n"; Output: (~) 54% math.pl Illegal division by zero at math.pl line 6. Forgetting to Make the Script Executable (~) 55% test.pl test.pl: Permission denied. Getting the Path to Perl Wrong on the #! line Code: #!/usr/local/bin/pearl # file: time.pl use strict; use warnings; $time = localtime; print "The time is now $time\n"; (~) 55% time.pl 6 of 20 time.pl: Command not found. This gives a very confusing error message because the command that wasn't found is 'pearl' not time.pl Useful Perl Command-Line Options You can call Perl with a few command-line options to help catch errors: -c Perform a syntax check, but don't run. -w Turn on verbose warnings. Same as use warnings; -d Turn on the Perl debugger. Usually you will invoke these from the command-line, as in perl -cw time.pl (syntax check time.pl with verbose warnings). You can also put them in the top line: #!/usr/bin/perl -w. Perl Statements A Perl script consists of a series of statements and comments. Each statement is a command that is recognized by the Perl interpreter and executed. Statements are terminated by the semicolon character (;). They are also usually separated by a newline character to enhance readability. A comment begins with the # sign and can appear anywhere. Everything from the # to the end of the line is ignored by the Perl interpreter. Commonly used for human-readable notes. Use comments plentifully, especially at the beginning of a script to describe what it does, at the beginning of each section of your code and for any complex code. Some Statements $sum = 2 + 2; # this is a statement $f = <STDIN>; $g = $f++; # these are two statements $g = $f / $sum; # this is one statement, spread across 3 lines The Perl interpreter will start at the top of the script and execute all the statements, in order from top to bottom, until it reaches the end of the script. This execution order can be modified by loops and control structures. Blocks It is common to group statements into blocks using curly braces. You can execute the entire block conditionally, or turn it into a subroutine that can be called from many different places. Example blocks: { # block starts 7 of 20 my $EcoRI = 'GAATTC'; my $sequence = <STDIN>; print "Sequence contains an EcoRI site" if $sequence=~/$EcoRI/; } # block ends my $sequence2 = <STDIN>; if (length($sequence) < 100) { # another block starts print "Sequence is too small. Throw it back\n"; exit 0; } # and ends foreach $sequence (@sequences) { # another block print "sequence length = ",length($sequence),"\n"; } Literals A literal is a constant value that you embed directly in the program code.
Recommended publications
  • Preview Objective-C Tutorial (PDF Version)
    Objective-C Objective-C About the Tutorial Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. This is the main programming language used by Apple for the OS X and iOS operating systems and their respective APIs, Cocoa and Cocoa Touch. This reference will take you through simple and practical approach while learning Objective-C Programming language. Audience This reference has been prepared for the beginners to help them understand basic to advanced concepts related to Objective-C Programming languages. Prerequisites Before you start doing practice with various types of examples given in this reference, I'm making an assumption that you are already aware about what is a computer program, and what is a computer programming language? Copyright & Disclaimer © Copyright 2015 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book can retain a copy for future reference but commercial use of this data is not allowed. Distribution or republishing any content or a part of the content of this e-book in any manner is also not allowed without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected] ii Objective-C Table of Contents About the Tutorial ..................................................................................................................................
    [Show full text]
  • Strings in C++
    Programming Abstractions C S 1 0 6 X Cynthia Lee Today’s Topics Introducing C++ from the Java Programmer’s Perspective . Absolute value example, continued › C++ strings and streams ADTs: Abstract Data Types . Introduction: What are ADTs? . Queen safety example › Grid data structure › Passing objects by reference • const reference parameters › Loop over “neighbors” in a grid Strings in C++ STRING LITERAL VS STRING CLASS CONCATENATION STRING CLASS METHODS 4 Using cout and strings int main(){ int n = absoluteValue(-5); string s = "|-5|"; s += " = "; • This prints |-5| = 5 cout << s << n << endl; • The + operator return 0; concatenates strings, } and += works in the way int absoluteValue(int n) { you’d expect. if (n<0){ n = -n; } return n; } 5 Using cout and strings int main(){ int n = absoluteValue(-5); But SURPRISE!…this one string s = "|-5|" + " = "; doesn’t work. cout << s << n << endl; return 0; } int absoluteValue(int n) { if (n<0){ n = -n; } return n; } C++ string objects and string literals . In this class, we will interact with two types of strings: › String literals are just hard-coded string values: • "hello!" "1234" "#nailedit" • They have no methods that do things for us • Think of them like integer literals: you can’t do "4.add(5);" //no › String objects are objects with lots of helpful methods and operators: • string s; • string piece = s.substr(0,3); • s.append(t); //or, equivalently: s+= t; String object member functions (3.2) Member function name Description s.append(str) add text to the end of a string s.compare(str) return
    [Show full text]
  • Xcode Package from App Store
    KH Computational Physics- 2016 Introduction Setting up your computing environment Installation • MAC or Linux are the preferred operating system in this course on scientific computing. • Windows can be used, but the most important programs must be installed – python : There is a nice package ”Enthought Python Distribution” http://www.enthought.com/products/edudownload.php – C++ and Fortran compiler – BLAS&LAPACK for linear algebra – plotting program such as gnuplot Kristjan Haule, 2016 –1– KH Computational Physics- 2016 Introduction Software for this course: Essentials: • Python, and its packages in particular numpy, scipy, matplotlib • C++ compiler such as gcc • Text editor for coding (for example Emacs, Aquamacs, Enthought’s IDLE) • make to execute makefiles Highly Recommended: • Fortran compiler, such as gfortran or intel fortran • BLAS& LAPACK library for linear algebra (most likely provided by vendor) • open mp enabled fortran and C++ compiler Useful: • gnuplot for fast plotting. • gsl (Gnu scientific library) for implementation of various scientific algorithms. Kristjan Haule, 2016 –2– KH Computational Physics- 2016 Introduction Installation on MAC • Install Xcode package from App Store. • Install ‘‘Command Line Tools’’ from Apple’s software site. For Mavericks and lafter, open Xcode program, and choose from the menu Xcode -> Open Developer Tool -> More Developer Tools... You will be linked to the Apple page that allows you to access downloads for Xcode. You wil have to register as a developer (free). Search for the Xcode Command Line Tools in the search box in the upper left. Download and install the correct version of the Command Line Tools, for example for OS ”El Capitan” and Xcode 7.2, Kristjan Haule, 2016 –3– KH Computational Physics- 2016 Introduction you need Command Line Tools OS X 10.11 for Xcode 7.2 Apple’s Xcode contains many libraries and compilers for Mac systems.
    [Show full text]
  • Variable Feature Usage Patterns in PHP
    Variable Feature Usage Patterns in PHP Mark Hills East Carolina University, Greenville, NC, USA [email protected] Abstract—PHP allows the names of variables, classes, func- and classes at runtime. Below, we refer to these generally as tions, methods, and properties to be given dynamically, as variable features, and specifically as, e.g., variable functions expressions that, when evaluated, return an identifier as a string. or variable methods. While this provides greater flexibility for programmers, it also makes PHP programs harder to precisely analyze and understand. The main contributions presented in this paper are as follows. In this paper we present a number of patterns designed to First, taking advantage of our prior work, we have developed recognize idiomatic uses of these features that can be statically a number of patterns for detecting idiomatic uses of variable resolved to a precise set of possible names. We then evaluate these features in PHP programs and for resolving these uses to a patterns across a corpus of 20 open-source systems totaling more set of possible names. Written using the Rascal programming than 3.7 million lines of PHP, showing how often these patterns occur in actual PHP code, demonstrating their effectiveness at language [2], [3], these patterns work over the ASTs of the statically determining the names that can be used at runtime, PHP scripts, with more advanced patterns also taking advantage and exploring anti-patterns that indicate when the identifier of control flow graphs and lightweight analysis algorithms for computation is truly dynamic. detecting value flow and reachability. Each of these patterns works generally across all variable features, instead of being I.
    [Show full text]
  • Strings String Literals String Variables Warning!
    Strings String literals • Strings are not a built-in data type. char *name = "csc209h"; printf("This is a string literal\n"); • C provides almost no special means of defining or working with strings. • String literals are stored as character arrays, but • A string is an array of characters you can't change them. terminated with a “null character” ('\0') name[1] = 'c'; /* Error */ • The compiler reserves space for the number of characters in the string plus one to store the null character. 1 2 String Variables Warning! • arrays are used to store strings • Big difference between a string's length • strings are terminated by the null character ('\0') and size! (That's how we know a string's length.) – length is the number of non-null characters • Initializing strings: currently present in the string – char course[8] = "csc209h"; – size if the amount of memory allocated for – char course[8] = {'c','s','c',… – course is an array of characters storing the string – char *s = "csc209h"; • Eg., char s[10] = "abc"; – s is a pointer to a string literal – length of s = 3, size of s = 10 – ensure length+1 ≤ size! 3 4 String functions Copying a string • The library provides a bunch of string char *strncpy(char *dest, functions which you should use (most of the char *src, int size) time). – copy up to size bytes of the string pointed to by src in to dest. Returns a pointer to dest. $ man string – Do not use strcpy (buffer overflow problem!) • int strlen(char *str) – returns the length of the string. Remember that char str1[3]; the storage needed for a string is one plus its char str2[5] = "abcd"; length /*common error*/ strncpy(str1, str2, strlen(str2));/*wrong*/ 5 6 Concatenating strings Comparing strings char *strncat(char *s1, const char *s2, size_t n); int strcmp(const char *s1, const char *s2) – appends the contents of string s2 to the end of s1, and returns s1.
    [Show full text]
  • VSI Openvms C Language Reference Manual
    VSI OpenVMS C Language Reference Manual Document Number: DO-VIBHAA-008 Publication Date: May 2020 This document is the language reference manual for the VSI C language. Revision Update Information: This is a new manual. Operating System and Version: VSI OpenVMS I64 Version 8.4-1H1 VSI OpenVMS Alpha Version 8.4-2L1 Software Version: VSI C Version 7.4-1 for OpenVMS VMS Software, Inc., (VSI) Bolton, Massachusetts, USA C Language Reference Manual Copyright © 2020 VMS Software, Inc. (VSI), Bolton, Massachusetts, USA Legal Notice Confidential computer software. Valid license from VSI required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. The information contained herein is subject to change without notice. The only warranties for VSI products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. VSI shall not be liable for technical or editorial errors or omissions contained herein. HPE, HPE Integrity, HPE Alpha, and HPE Proliant are trademarks or registered trademarks of Hewlett Packard Enterprise. Intel, Itanium and IA64 are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. Java, the coffee cup logo, and all Java based marks are trademarks or registered trademarks of Oracle Corporation in the United States or other countries. Kerberos is a trademark of the Massachusetts Institute of Technology.
    [Show full text]
  • Strings String Literals Continuing a String Literal Operations on String
    3/4/14 String Literals • A string literal is a sequence of characters enclosed within double quotes: "When you come to a fork in the road, take it." Strings • String literals may contain escape sequences. • Character escapes often appear in printf and scanf format strings. Based on slides from K. N. King and Dianna Xu • For example, each \n character in the string "Candy\nIs dandy\nBut liquor\nIs quicker.\n --Ogden Nash\n" causes the cursor to advance to the next line: Bryn Mawr College Candy CS246 Programming Paradigm Is dandy But liquor Is quicker. --Ogden Nash Continuing a String Literal How String Literals Are Stored • The backslash character (\) • The string literal "abc" is stored as an array of printf("When you come to a fork in the road, take it. \ four characters: --Yogi Berra"); Null o In general, the \ character can be used to join two or character more lines of a program into a single line. • When two or more string literals are adjacent, the compiler will join them into a single string. • The string "" is stored as a single null character: printf("When you come to a fork in the road, take it. " "--Yogi Berra"); This rule allows us to split a string literal over two or more lines How String Literals Are Stored Operations on String Literals • Since a string literal is stored as an array, the • We can use a string literal wherever C allows a compiler treats it as a pointer of type char *. char * pointer: • Both printf and scanf expect a value of type char *p; char * as their first argument.
    [Show full text]
  • Failed to Download the Gnu Archive Emacs 'Failed to Download `Marmalade' Archive', but I See the List in Wireshark
    failed to download the gnu archive emacs 'Failed to download `marmalade' archive', but I see the list in Wireshark. I've got 129 packets from marmalade-repo.org , many of which list Marmalade package entries, in my Wireshark log. I'm not behind a proxy and HTTP_PROXY is unset. And ELPA (at 'http://tromey.com/elpa/') works fine. I'm on Max OS X Mavericks, all-up-to-date, with Aquamacs, and using the package.el (byte-compiled) as described here: http://marmalade- repo.org/ (since I am on < Emacs 24). What are the next troubleshooting steps I should take? 1 Answer 1. I've taken Aaron Miller's suggestion and fully migrated to the OS X port of Emacs 24.3 . I do miss being able to use the 'command' key to go to the top of the current file, and the slightly smoother gui of Aquamacs, but it's no doubt a great port. Due to the issue with Marmalade, Emacs 23.4 won't work with some of the packages I now need (unless they were hand-built). Installing ELPA Package System for Emacs 23. This page is a guide on installing ELPA package system package.el for emacs 23. If you are using emacs 24, see: Emacs: Install Package with ELPA/MELPA. (type Alt + x version or in terminal emacs --version .) To install, paste the following in a empty file: then call eval-buffer . That will download the file and place it at. (very neat elisp trick! note to self: url-retrieve-synchronously is bundled with emacs 23.
    [Show full text]
  • Data Types in C
    Princeton University Computer Science 217: Introduction to Programming Systems Data Types in C 1 Goals of C Designers wanted C to: But also: Support system programming Support application programming Be low-level Be portable Be easy for people to handle Be easy for computers to handle • Conflicting goals on multiple dimensions! • Result: different design decisions than Java 2 Primitive Data Types • integer data types • floating-point data types • pointer data types • no character data type (use small integer types instead) • no character string data type (use arrays of small ints instead) • no logical or boolean data types (use integers instead) For “under the hood” details, look back at the “number systems” lecture from last week 3 Integer Data Types Integer types of various sizes: signed char, short, int, long • char is 1 byte • Number of bits per byte is unspecified! (but in the 21st century, pretty safe to assume it’s 8) • Sizes of other integer types not fully specified but constrained: • int was intended to be “natural word size” • 2 ≤ sizeof(short) ≤ sizeof(int) ≤ sizeof(long) On ArmLab: • Natural word size: 8 bytes (“64-bit machine”) • char: 1 byte • short: 2 bytes • int: 4 bytes (compatibility with widespread 32-bit code) • long: 8 bytes What decisions did the designers of Java make? 4 Integer Literals • Decimal: 123 • Octal: 0173 = 123 • Hexadecimal: 0x7B = 123 • Use "L" suffix to indicate long literal • No suffix to indicate short literal; instead must use cast Examples • int: 123, 0173, 0x7B • long: 123L, 0173L, 0x7BL • short:
    [Show full text]
  • The ASCII Character Set Strings and Characters
    Characters and Strings 57:017, Computers in Introduction Engineering—Quick Review Fundamentals of Strings and Characters of C Character Strings Character Handling Library String Conversion Functions Standard Input/Output Library Functions String Manipulation Functions of the String Handling Library Comparison Functions of the String Handling Library Search Functions of the String Handling Library Other Functions of the String Handling Library Fundamentals of Strings Introduction and Characters z Introduce some standard library functions z Characters z Easy string and character processing z Character constant z Programs can process characters, strings, lines of z represented as a character in single quotes text, and blocks of memory z 'z' represents the integer value of z z stored in ASCII format ((yone byte/character) z These techniques used to make: z Strings z Word processors z Series of characters treated as a single unit z Can include letters, digits and special characters (*, /, $) z Page layout software z String literal (string constant) - written in double quotes z Typesetting programs z "Hello" z etc. z Strings are arrays of characters z The type of a string is char * i.e. “pointer to char” z Value of string is the address of first character The ASCII Character Set Strings and Characters z String declarations z Declare as a character array or a variable of type char * char color[] = "blue"; char *colorPtr = "blue"; z Remember that strings represented as character arrays end with '\0' z color has 5 eltlements z Inputting strings z Use scanf char word[10]; scanf("%s", word); z Copies input into word[] z Do not need & (because word is a pointer) z Remember to leave room in the array for '\0' 1 Chars as Ints Inputting Strings using scanf char word[10]; z Since characters are stored in one-byte ASCII representation, char *wptr; they can be considered as one-byte integers.
    [Show full text]
  • Ledger Mode Emacs Support for Version 3.0 of Ledger
    Ledger Mode Emacs Support For Version 3.0 of Ledger Craig Earls Copyright c 2013, Craig Earls. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are per- mitted provided that the following conditions are met: • Redistributions of source code must retain the above copyright notice, this list of con- ditions 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 New Artisans LLC 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 CONTRIBU- TORS \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. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAM- AGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTER- RUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. i Table of Contents
    [Show full text]
  • Latex on Macintosh
    LaTeX on Macintosh Installing MacTeX and using TeXShop, as described on the main LaTeX page, is enough to get you started using LaTeX on a Mac. This page provides further information for experienced users. Tips for using TeXShop Forward and Inverse Search If you are working on a long document, forward and inverse searching make editing much easier. • Forward search means jumping from a point in your LaTeX source file to the corresponding line in the pdf output file. • Inverse search means jumping from a line in the pdf file back to the corresponding point in the source file. In TeXShop, forward and inverse search are easy. To do a forward search, right-click on text in the source window and choose the option "Sync". (Shortcut: Cmd-Click). Similarly, to do an inverse search, right-click in the output window and choose "Sync". Spell-checking TeXShop does spell-checking using Apple's built in dictionaries, but the results aren't ideal, since TeXShop will mark most LaTeX commands as misspellings, and this will distract you from the real misspellings in your document. Below are two ways around this problem. • Use the spell-checking program Excalibur which is included with MacTeX (in the folder / Applications/TeX). Before you start spell-checking with Excalibur, open its Preferences, and in the LaTeX section, turn on "LaTeX command parsing". Then, Excalibur will ignore LaTeX commands when spell-checking. • Install CocoAspell (already installed in the Math Lab), then go to System Preferences, and open the Spelling preference pane. Choose the last dictionary in the list (the third one labeled "English (United States)"), and check the box for "TeX/LaTeX filtering".
    [Show full text]