Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.

Size: px
Start display at page:

Download "Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc."

Transcription

1 Appendix B WORKSHOP SYS-ED/ Computer Education Techniques, Inc.

2 1 Scalar Variables 1. Write a Perl program that reads in a number, multiplies it by 2, and prints the result. 2. Write a Perl program that reads in two numbers and does the following: It prints Error: can't divide by zero if the second number is 0. If the first number is 0 or the second number is 1, it just prints the first number (because no division is necessary). In all other cases, it divides the first number by the second number and prints the result. 3. Write a Perl program that uses the while statement to print out the first 10 numbers (1-10) in ascending order. 4. Write a Perl program that uses the until statement to print out the first 10 numbers in descending order (10-1). COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 1

3 1.1 Solutions - Scalar Variables 1. One solution: print ("Enter a number to be multiplied by 2:\n"); $number = <STDIN>; chop ($number); $number = $number * 2; print ("The result is ", $number, "\n"); 2. Another solution would be: print ("Enter the dividend (number to divide):\n"); $dividend = <STDIN>; chop ($dividend); print ("Enter the divisor (number to divide by):\n"); $divisor = <STDIN>; chop ($divisor); if ($divisor == 0) { print ("Error: can't divide by zero!\n"); elsif ($dividend == 0) { $result = $dividend; elsif ($divisor == 1) { $result = $dividend; else { $result = $divisor / $dividend; if ($divisor == 0) { # skip the print, since we detected an error else { print ("The result is ", $result, "\n"); 3. One solution would be: $count = 1; $done = 0; while ($done == 0) { print ($count, "\n"); if ($count == 10) { $done = 1; $count = $count + 1; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 2

4 A solution is: $count = 10; until ($count == 0) { print ($count, "\n"); $count = $count - 1; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 3

5 2 Perl Operators 1. Write a program that uses the << operator to print out the first 16 powers of Rewrite the following statement using the conditional operator: if ($var1 == 5 $var2 == 7) { $result = $var1 * $var ; else { print("condition is false\n"); $result = 0; 3. Rewrite the following expression using the if and else statements: $result = $var1 <= 26? ++$var2 : 0; 4. Write a program that reads two integers from standard input (one at a time), divides the first one by the second one, and prints out the quotient (the result) and the remainder. 5. Why might the following statement not assign the value 5.1 to $result? $result = ; 6. Determine the order of operations in the following statement, and add parentheses to the statement to indicate this order: $result = $var1 * 2 << $var2 ** 3, $var3; 7. What value is assigned to $result by the following code? $var1 = 43; $var2 = 16; $result = ++$var2 == 17? $var1++ * 2-5 : ++$var1 * 3-11; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 4

6 2.1 Solutions - Perl Operators 1. This is one of several answers: $value = 1; $counter = 0; while ($counter < 16) { print ("2 to the power $counter is $value\n"); $value = $value << 1; $counter++; 2. The answer is: $result = $var1 == 5 $var2 == 7? $var1 * $var : (print("condition is false\n"), 0); 3. The answer is: if ($var1 <= 26) { $result = ++$var2; else { $result = 0; 4. This is one of several answers: print("enter the integer to be divided:\n"); $dividend = <STDIN>; print("enter the integer to divide by:\n"); $divisor = <STDIN>; # check for division by zero if ($divisor == 0) { print("error: can't divide by zero\n"); else { $quotient = $dividend / $divisor; $remainder = $dividend % $divisor; print("the result is $quotient\n"); print("the remainder is $remainder\n"); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 5

7 5. Adding and then subtracting it will cause errors in rounding. This means that the final value will not be identical to ($result = ((($var1 * 2) << (5 + 3)) ($var2 ** 3))), $var3; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 6

8 3 Arrays 1. Write a program that counts all occurrences of the word the in the standard input file. 2. Write a program that reads lines of input containing numbers, each of which is separated by exactly one space, and prints out the following: a. The total for each line b. The grand total 3. Write a program that reads all input from the standard input file and sorts all the words in reverse order, printing out one word per line with duplicates omitted. COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 7

9 3.1 Solutions - Arrays 1. One solution is: $thecount = 0; $line = <STDIN>; while ($line ne "") { chop = split(/ /, $line); $wordindex = 1; while ($wordindex { if ($words[$wordindex-1] eq "the") { $thecount += 1; $wordindex++; $line = <STDIN>; print ("Total occurrences of \"the\": $thecount\n"); 2. Another solution is: $grandtotal = 0; $line = <STDIN>; while ($line ne "") { $linetotal = = split(/ /, $line); $numbercount = 1; while ($numbercount { $linetotal += $numbers[$numbercount-1]; $numbercount++; print("line total: $linetotal\n"); $grandtotal += $linetotal; $line = <STDIN>; print("grand total: $grandtotal\n"); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 8

10 3. One solution = <STDIN>; chop (@lines); $longlongline = = split(/ /, = reverse sort (@words); $index = 0; print("words sorted in reverse order:\n"); while ($index { # note that the first time through, the following # comparison references $words[-1]. This is all # right, as $words[-1] is replaced by the null # string, and we want the first word to be printed if ($words[$index] ne $words[$index-1]) { print ("$words[$index]\n"); $index++; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 9

11 4 I/O 1. Write a program that takes the values on the command line, adds them together, and prints the result. 2. Write a program that takes a list of files from the command line and examines their size. If a file is bigger than 10,000 bytes, print; File name is a big file! where name is a placeholder for the name of the big file. 3. Write a program that copies a file named file1 to file2, and then appends another copy of file1 to file2. 4. Write a program that counts the total number of words in the files specified on the command line. After it has counted the words, a message is sent to user ID dave indicating the total number of words. 5. Write a program that takes a list of files and indicates, for each file, whether the user has read, write, or execute permission. COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 10

12 4.1 Solutions - I/O 1. One solution is: $total = 0; $count = 1; while ($count { $total += $ARGV[$count-1]; $count++; print ("The total is $total.\n"); 2. Another solution is: $count = 1; while ($count { if (-e $ARGV[$count-1] && -s $ARGV[$count-1] > 10000) { print ("File $ARGV[$count-1] is a big file!\n"); $count++; 3. One solution is: open (INFILE, "file1") die ("Can't open file1 for reading\n"); open (OUTFILE, ">file2") die ("Can't open file2 for writing\n"); # the following only works if file1 isn't too = <INFILE>; print OUTFILE (@contents); # we don't really need the call to close, but they # make things a little clearer close (OUTFILE); open (OUTFILE, ">>file2") die ("Can't append to file2\n"); print OUTFILE (@contents); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 11

13 4. One solution is: $wordcount = 0; while ($line = <>) { # this isn't the best possible pattern to split with, # but it'll do until you've finished Day = split(/ /, $line); $wordcount open (MESSAGE, " mail dave") die ("Can't mail to userid dave.\n"); print MESSAGE ("Total number of words: $wordcount\n"); close (MESSAGE); 5. One solution is: $count = 1; while ($count { print ("File $ARGV[$count-1]:"); if (!(-e $ARGV[$count-1])) { print (" does not exist\n"); else { if (-r $ARGV[$count-1]) { print (" read"); if (-w $ARGV[$count-1]) { print (" write"); if (-x $ARGV[$count-1]) { print (" execute"); print ("\n"); $count++; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 12

14 5 Patterns 1. Write a program that reads all the input from the standard input file, converts all the vowels (except y) to uppercase, and prints the result on the standard output file. 2. Write a program that counts the number of times each digit appears in the standard input file. Print the total for each digit and the sum of all the totals. 3. Write a program that reverses the order of the first three words of each input line (from the standard input file) using the substitution operator. Leave the spacing unchanged, and print each resulting line. 4. Write a program that adds 1 to every number in the standard input file. Print the results. COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 13

15 5.1 Solutions - Patterns 1. One solution is: while ($line = <STDIN>) { $line =~ tr/aeiou/aeiou/; print ($line); 2. Another solution is: while ($inputline = <STDIN>) { $inputline =~ tr/0-9/ /c; $inputline =~ s/ = split(//, $inputline); $total $count = 1; while ($count { $dtotal[$digits[$count-1]] += 1; $count++; print ("Total number of digits found: $total\n"); print ("Breakdown:\n"); $count = 0; while ($count <= 9) { if ($dtotal[$count] > 0) { print ("\tdigit $count: $dtotal[$count]\n"); $count++; 3. One solution is: while ($line = <STDIN>) { $line =~ s/(\w+)(\s+)(\w+)(\s+)(\w+)/$5$2$3$4$1/; print ($line); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 14

16 4. One solution is: while ($line = <STDIN>) { $line =~ s/\d+/$&+1/eg; print ($line); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 15

17 6 Control 1. Write a program that uses the do statement to print the numbers from 1 to Write a program that uses the for statement to print the numbers from 1 to Write a program that uses a loop to read and write five lines of input. Use the last statement to exit the loop if there are less than five lines to read. 4. Write a program that loops through the numbers 1 to 20, printing the even-numbered values. Use the next statement to skip over the odd-numbered values. 5. Write a program that uses the foreach statement to check each word in the standard input file. Print the line numbers of all occurrences of the word the (in uppercase, lowercase, or mixed case). 6. Write a program that uses a while loop and a continue statement to print the integers from 10 down to 1. COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 16

18 6.1 Solution - Control 1. One solution is: $count = 1; do { print ("$count\n"); $count++; while ($count <= 10); 2. One solution is: for ($count = 1; $count <= 10; $count++) { print ("$count\n"); 3. One solution is: for ($count = 1; $count <= 5; $count++) { $line = <STDIN>; last if ($line eq ""); print ($line); 4. One solution is: for ($count = 1; $count <= 20; $count++) { next if ($count % 2 == 1); print ("$count\n"); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 17

19 5. One solution is: $linenum = 0; while ($line = <STDIN>) { $linenum += 1; $occurs = 0; $line =~ = split(/\s+/, $line); foreach $word (@words) { $occurs += 1 if ($word eq "the"); if ($occurs > 0) { print ("line $linenum: $occurs occurrences\n"); 6. One solution is: $count = 10; while ($count >= 1) { print ("$count\n"); continue { $count-; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 18

20 6.2 Subroutines 1. Write a subroutine that takes two arguments, adds them together, and returns the result. 2. Write a subroutine that counts the number of occurrences of the letter t in a string which will then be passed to the subroutine. The subroutine must return the number of occurrences. 3. Write a subroutine that takes two filenames as its arguments and returns a nonzero value if the two files have identical contents. Return 0 if the files differ. 4. Write a subroutine that simulates the roll of a die (that is, it generates a random number between 1 and 6) and returns the number. COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 19

21 6.3 Solutions - Subroutines 1. One solution is: sub add_two { local ($arg1, $arg2) $result = $arg1 + $arg2; 2. Another solution is: sub count_t { local ($string) # There are a couple of tricks you can use to do this. # This one splits the string into words using "t" as # the split pattern. The number of occurrences of "t" # is one less than the number of words resulting from # the = split(/t/, $string); $retval - 1; 3. Another solution is: sub diff { local ($file1, $file2) # return false if we can't open a file return (0) unless open (FILE1, "$file1"); return (0) unless open (FILE2, "$file2"); while (1) { $line1 = <FILE1>; $line2 = <FILE2>; if ($line1 eq "") { $retval = ($line2 eq ""); last; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 20

22 if ($line2 eq "" $line1 ne $line2) { $retval = 0; last; # you should use close here, as this subroutine may # be called many times close (FILE1); close (FILE2); # ensure that the return value is the last evaluated # expression $retval; 4. One solution is: sub dieroll { $retval = int (rand(6)) + 1; COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 21

23 7 Associative Arrays 1. Write a program that reads lines of input consisting of two words per line, such as bananas 16 and creates an associative array from these lines. The first word is to be the subscript and the second word the value. 2. Write a program that reads a file and searches for lines of the form index word where word is a word to be indexed. Each indexed word is to be stored in an associative array, along with the line number on which it first occurs. Subsequent occurrences can be ignored. Print the resulting index. 3. Modify the program created in Exercise 2 to store every occurrence of each index line. Try building the associative array subscripts using the indexed word, a non-printable character, and a number. Print the resulting index. 4. Write a program that reads input lines consisting of a student name and five numbers representing the student's marks in English, history, mathematics, science, and geography, as follows: Jones Use an associative array to store these numbers in a database. Print out the names of all students with failing grades, grade less than 50, along with the subjects they failed. COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 22

24 7.1 Solutions - Associative Arrays 1. One solution is: while ($line = <STDIN>) { $line =~ s/^\s+ \s+$//g; ($subscript, $value) = split(/\s+/, $line); $array{$subscript = $value; 2. One solution is: $linenum = 0; while ($line = <STDIN>) { $linenum += 1; $line =~ s/^\s+ = split(/\s+/, $line); if ($words[0] eq "index" && $index{$words[1] eq "") { $index{$words[1] = $linenum; foreach $item (sort keys (%index)) { print ("$item: $index{$item\n"); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 23

25 3. One solution is: $linenum = 0; while ($line = <STDIN>) { $linenum += 1; $line =~ s/^\s+ = split(/\s+/, $line); # This program uses a trick: for each word, the array # item $index{"word" stores the number of occurrences # of that word. Each occurrence is stored in the # element $index{"word#n", where[]is a # positive integer. if ($words[0] eq "index") { if ($index{$words[1] eq "") { $index{$words[1] = 1; $occurrence = 1; else { $index{$words[1] += 1; $occurrence = $index{$words[1]; $index{$words[1]."#".$occurrence = $linenum; # The loop that prints the index takes advantage of the fact # that, when the list is sorted, the elements that count # occurrences are always processed just before the # corresponding elements that store occurrences. For example: # $index{word # $index{word#1 # $index{word#2 COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 24

26 foreach $item (sort keys (%index)) { if ($item =~ /#/) { print ("\n$item:"); else { print (" $index{$item"); print ("\n"); 4. One solution is: $student = = ("English", "history", "mathematics", "science", "geography"); while ($line = <STDIN>) { $line =~ s/^\s+ = split (/\s+/, = $words[0]; for ($count = 1; $count <= 5; $count++) { $marks{$words[0].$subjects[$count-1] = $words[$count]; # now print the failing grades, one student per line foreach $student (sort (@students)) { $has_failed = 0; foreach $subject (sort (@subjects)) { if ($marks{$student.$subject < 50) { if ($has_failed == 0) { $has_failed = 1; print ("$student failed:"); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 25

27 print (" $subject"); if ($has_failed == 1) { print ("\n"); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 26

28 8 Directories 1. Write a program that reads the directory /u/jqpublic and prints out all file and directory names that start with a period. Ignore the special files. (one period) and.. (two periods). 2. Write a program that lists all the files in the directory /u/jqpublic and then lists the contents of any subdirectories, their subdirectories, and so on. Use a recursive subroutine. 3. Write a program that uses readdir and rewinddir to read a directory named /u/jqpublic and print a sorted list of the files and directories in alphabetical order. Ignore all names beginning with a period. 4. Write a program that uses hot keys and does the following: Reads single digits and prints out their English-language equivalents. Terminates if it reads the Esc (escape) character. Ignores all other input. Prints out one English word per line. COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 27

29 8.1 Solutions - Directories 1. One solution is: opendir (MYDIR, "/u/jqpublic") die ("Can't open directory"); while ($file = readdir (MYDIR)) { next if ($file =~ /^\.{1,2$ ^[^.]/); print ("$file\n"); closedir (MYDIR); 2.One solution is: $filecount = 1; &print_dir ("/u/jqpublic"); sub print_dir { local ($dirname) local ($file, $subdir, $filevar); $filevar = "MYFILE". $filecount++; opendir ($filevar, $dirname) die ("Can't open directory"); # first pass: read and print file names print ("\ndirectory $dirname:\n"); while ($file = readdir ($filevar)) { next if ($file eq "." $file eq ".."); next if (-d ($dirname. "/". $file)); print ("$file\n"); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 28

30 # second pass: recursively print subdirectories rewinddir ($filevar); while ($subdir = readdir ($filevar)) { next unless (-d ($dirname. "/". $subdir)); next if ($subdir eq "." $subdir eq ".."); &print_dir ($dirname. "/". $subdir); closedir ($filevar); 3. One solution is: opendir (MYDIR, "/u/jqpublic") die ("Can't open directory"); # the following is a trick: "." is alphabetically less than # anything we want to print, so it makes a handy # initial value $lastfile = "."; until (1) { rewinddir (MYDIR); $currfile = ""; while ($file = readdir (MYDIR)) { next if ($file =~ /^\./); if ($file gt $lastfile && ($currfile eq "" $file lt $currfile)) { $currfile = $file; last if ($currfile eq ""); print ("$currfile\n"); $lastfile = $currfile; closedir (MYDIR); COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 29

31 4. One solution = ("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"); &start_hot_keys; while (1) { $char = getc(stdin); last if ($char eq "\033"); next if ($char =~ /[^0-9]/); print ("$digits[$char]\n"); &end_hot_keys; sub start_hot_keys { system ("stty cbreak"); system ("stty -echo"); sub end_hot_keys { system ("stty -cbreak"); system ("stty echo"); D:\05_Courseware_2006\UNIX_Advanced\09_App_B_UNIX_Fundamentals_Advanced_Wo rkshop_qc.doc COMPUTER EDUCATION TECHNIQUES, INC. (UNIX-Fund: Level 2-6.5) App B: Page 30

Perl Programming. Bioinformatics Perl Programming

Perl Programming. Bioinformatics Perl Programming Bioinformatics Perl Programming Perl Programming Regular expressions A regular expression is a pattern to be matched against s string. This results in either a failure or success. You may wish to go beyond

More information

Outline. CS3157: Advanced Programming. Feedback from last class. Last plug

Outline. CS3157: Advanced Programming. Feedback from last class. Last plug Outline CS3157: Advanced Programming Lecture #2 Jan 23 Shlomo Hershkop shlomo@cs.columbia.edu Feedback Introduction to Perl review and continued Intro to Regular expressions Reading Programming Perl pg

More information

Pathologically Eclectic Rubbish Lister

Pathologically Eclectic Rubbish Lister Pathologically Eclectic Rubbish Lister 1 Perl Design Philosophy Author: Reuben Francis Cornel perl is an acronym for Practical Extraction and Report Language. But I guess the title is a rough translation

More information

Bamuengine.com. Chapter 14. Perl The Mater Manipulator

Bamuengine.com. Chapter 14. Perl The Mater Manipulator Chapter 14. Perl The Mater Manipulator Introduciton The following sections tell you what Perl is, the variables and operators in perl, the string handling functions. The chapter also discusses file handling

More information

What is PERL?

What is PERL? Perl For Beginners What is PERL? Practical Extraction Reporting Language General-purpose programming language Creation of Larry Wall 1987 Maintained by a community of developers Free/Open Source www.cpan.org

More information

COMS 3101 Programming Languages: Perl. Lecture 2

COMS 3101 Programming Languages: Perl. Lecture 2 COMS 3101 Programming Languages: Perl Lecture 2 Fall 2013 Instructor: Ilia Vovsha http://www.cs.columbia.edu/~vovsha/coms3101/perl Lecture Outline Control Flow (continued) Input / Output Subroutines Concepts:

More information

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs Summer 2010 Department of Computer Science and Engineering York University Toronto June 29, 2010 1 / 36 Table of contents 1 2 3 4 2 / 36 Our goal Our goal is to see how we can use Unix as a tool for developing

More information

Shell programming. Introduction to Operating Systems

Shell programming. Introduction to Operating Systems Shell programming Introduction to Operating Systems Environment variables Predened variables $* all parameters $# number of parameters $? result of last command $$ process identier $i parameter number

More information

Introduction to Perl. Perl Background. Sept 24, 2007 Class Meeting 6

Introduction to Perl. Perl Background. Sept 24, 2007 Class Meeting 6 Introduction to Perl Sept 24, 2007 Class Meeting 6 * Notes on Perl by Lenwood Heath, Virginia Tech 2004 Perl Background Practical Extraction and Report Language (Perl) Created by Larry Wall, mid-1980's

More information

Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality, Operations and Algebraic Thinking, Number and Operations in Base 10)

Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality, Operations and Algebraic Thinking, Number and Operations in Base 10) Kindergarten 1 Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality,, Number and Operations in Base 10) Kindergarten Counting and Cardinality Know number names and the count sequence.

More information

Adding and Subtracting with Decimals

Adding and Subtracting with Decimals Adding and Subtracting with Decimals Before you can add or subtract numbers with decimals, all the decimal points must be lined up. (It will help if you use zeros to fill in places so that the numbers

More information

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell.

Command Interpreters. command-line (e.g. Unix shell) On Unix/Linux, bash has become defacto standard shell. Command Interpreters A command interpreter is a program that executes other programs. Aim: allow users to execute the commands provided on a computer system. Command interpreters come in two flavours:

More information

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT Unix as a Platform Exercises + Solutions Course Code: OS 01 UNXPLAT Working with Unix Most if not all of these will require some investigation in the man pages. That's the idea, to get them used to looking

More information

There are some string operators that can be used in the test statement to perform string comparison.

There are some string operators that can be used in the test statement to perform string comparison. ACS-294- Unix (Winter Term, 26-7) Part II: Shell Programming Page 3 The test also returns a nonzero exit value if there is no argument: test String Operators There are some string operators that can be

More information

Programming Perls* Objective: To introduce students to the perl language.

Programming Perls* Objective: To introduce students to the perl language. Programming Perls* Objective: To introduce students to the perl language. Perl is a language for getting your job done. Making Easy Things Easy & Hard Things Possible Perl is a language for easily manipulating

More information

COMP 4/6262: Programming UNIX

COMP 4/6262: Programming UNIX COMP 4/6262: Programming UNIX Lecture 12 shells, shell programming: passing arguments, if, debug March 13, 2006 Outline shells shell programming passing arguments (KW Ch.7) exit status if (KW Ch.8) test

More information

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers A Big Step Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Copyright 2006 2009 Stewart Weiss What a shell really does Here is the scoop on shells. A shell is a program

More information

1.1 Review of Place Value

1.1 Review of Place Value 1 1.1 Review of Place Value Our decimal number system is based upon powers of ten. In a given whole number, each digit has a place value, and each place value consists of a power of ten. Example 1 Identify

More information

CS Unix Tools & Scripting

CS Unix Tools & Scripting Cornell University, Spring 2014 1 February 24, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater A note on awk for (item in array) The order in which items are returned

More information

A shell can be used in one of two ways:

A shell can be used in one of two ways: Shell Scripting 1 A shell can be used in one of two ways: A command interpreter, used interactively A programming language, to write shell scripts (your own custom commands) 2 If we have a set of commands

More information

Indian Institute of Technology Kharagpur. PERL Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T.

Indian Institute of Technology Kharagpur. PERL Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Indian Institute of Technology Kharagpur PERL Part III Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 23: PERL Part III On completion, the student will be able

More information

Control Structures. CIS 118 Intro to LINUX

Control Structures. CIS 118 Intro to LINUX Control Structures CIS 118 Intro to LINUX Basic Control Structures TEST The test utility, has many formats for evaluating expressions. For example, when given three arguments, will return the value true

More information

Chapter 4 Section 2 Operations on Decimals

Chapter 4 Section 2 Operations on Decimals Chapter 4 Section 2 Operations on Decimals Addition and subtraction of decimals To add decimals, write the numbers so that the decimal points are on a vertical line. Add as you would with whole numbers.

More information

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value 1 Number System Introduction In this chapter, we will study about the number system and number line. We will also learn about the four fundamental operations on whole numbers and their properties. Natural

More information

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1 Shell Scripting Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 If we have a set of commands that we want to run on a regular basis, we could write a script A script acts as a Linux command,

More information

Scripting Languages Perl Basics. Course: Hebrew University

Scripting Languages Perl Basics. Course: Hebrew University Scripting Languages Perl Basics Course: 67557 Hebrew University אליוט יפה Jaffe Lecturer: Elliot FMTEYEWTK Far More Than Everything You've Ever Wanted to Know Perl Pathologically Eclectic Rubbish Lister

More information

Chapter 8. More Control Statements

Chapter 8. More Control Statements Chapter 8. More Control Statements 8.1 for Statement The for statement allows the programmer to execute a block of code for a specified number of times. The general form of the for statement is: for (initial-statement;

More information

Regular expressions and case insensitivity

Regular expressions and case insensitivity Regular expressions and case insensitivity As previously mentioned, you can make matching case insensitive with the i flag: /\b[uu][nn][ii][xx]\b/; /\bunix\b/i; # explicitly giving case folding # using

More information

Regular expressions and case insensitivity

Regular expressions and case insensitivity Regular expressions and case insensitivity As previously mentioned, you can make matching case insensitive with the i flag: /\b[uu][nn][ii][xx]\b/; # explicitly giving case folding /\bunix\b/i; # using

More information

They grow as needed, and may be made to shrink. Officially, a Perl array is a variable whose value is a list.

They grow as needed, and may be made to shrink. Officially, a Perl array is a variable whose value is a list. Arrays Perl arrays store lists of scalar values, which may be of different types. They grow as needed, and may be made to shrink. Officially, a Perl array is a variable whose value is a list. A list literal

More information

Bourne Shell Reference

Bourne Shell Reference > Linux Reviews > Beginners: Learn Linux > Bourne Shell Reference Bourne Shell Reference found at Br. David Carlson, O.S.B. pages, cis.stvincent.edu/carlsond/cs330/unix/bshellref - Converted to txt2tags

More information

Indian Institute of Technology Kharagpur. PERL Part II. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T.

Indian Institute of Technology Kharagpur. PERL Part II. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Indian Institute of Technology Kharagpur PERL Part II Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 22: PERL Part II On completion, the student will be able

More information

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Scripting Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss What a shell

More information

(Refer Slide Time: 01:12)

(Refer Slide Time: 01:12) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #22 PERL Part II We continue with our discussion on the Perl

More information

Perl. Many of these conflict with design principles of languages for teaching.

Perl. Many of these conflict with design principles of languages for teaching. Perl Perl = Practical Extraction and Report Language Developed by Larry Wall (late 80 s) as a replacement for awk. Has grown to become a replacement for awk, sed, grep, other filters, shell scripts, C

More information

CS 230 Programming Languages

CS 230 Programming Languages CS 230 Programming Languages 09 / 16 / 2013 Instructor: Michael Eckmann Today s Topics Questions/comments? Continue Syntax & Semantics Mini-pascal Attribute Grammars More Perl A more complex grammar Let's

More information

Provided by - Microsoft Placement Paper Technical 2012

Provided by   - Microsoft Placement Paper Technical 2012 Provided by www.yuvajobs.com - Microsoft Placement Paper Technical 2012 1. Analytical 25 questions ( 30 minutes) 2. Reasoning 25 questions (25 minutes) 3. Verbal 20 questions (20 minutes) Analytical (some

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

Perl. Perl. Perl. Which Perl

Perl. Perl. Perl. Which Perl Perl Perl Perl = Practical Extraction and Report Language Developed by Larry Wall (late 80 s) as a replacement for awk. Has grown to become a replacement for awk, sed, grep, other filters, shell scripts,

More information

Bioinformatics. Computational Methods II: Sequence Analysis with Perl. George Bell WIBR Biocomputing Group

Bioinformatics. Computational Methods II: Sequence Analysis with Perl. George Bell WIBR Biocomputing Group Bioinformatics Computational Methods II: Sequence Analysis with Perl George Bell WIBR Biocomputing Group Sequence Analysis with Perl Introduction Input/output Variables Functions Control structures Arrays

More information

OPERATING SYSTEMS LAB LAB # 6. I/O Redirection and Shell Programming. Shell Programming( I/O Redirection and if-else Statement)

OPERATING SYSTEMS LAB LAB # 6. I/O Redirection and Shell Programming. Shell Programming( I/O Redirection and if-else Statement) P a g e 1 OPERATING SYSTEMS LAB LAB 6 I/O Redirection and Shell Programming Lab 6 Shell Programming( I/O Redirection and if-else Statement) P a g e 2 Redirection of Standard output/input i.e. Input - Output

More information

50 MATHCOUNTS LECTURES (6) OPERATIONS WITH DECIMALS

50 MATHCOUNTS LECTURES (6) OPERATIONS WITH DECIMALS BASIC KNOWLEDGE 1. Decimal representation: A decimal is used to represent a portion of whole. It contains three parts: an integer (which indicates the number of wholes), a decimal point (which separates

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

Cisco IOS Shell. Finding Feature Information. Prerequisites for Cisco IOS.sh. Last Updated: December 14, 2012

Cisco IOS Shell. Finding Feature Information. Prerequisites for Cisco IOS.sh. Last Updated: December 14, 2012 Cisco IOS Shell Last Updated: December 14, 2012 The Cisco IOS Shell (IOS.sh) feature provides shell scripting capability to the Cisco IOS command-lineinterface (CLI) environment. Cisco IOS.sh enhances

More information

Division. Reverse Box Method

Division. Reverse Box Method Division Reverse Box Method Why do we use the reverse box method? The box method of multiplication is used because it develops a strong conceptual understanding of multiplication! If you have not read

More information

Script Programming Systems Skills in C and Unix

Script Programming Systems Skills in C and Unix Script Programming with Perl II 15-123 Systems Skills in C and Unix Subroutines sub sum { return $a + $b; } So we can call this as: $a = 12; $b = 10; $sum = sum(); print the sum is $sum\n ; Passing Arguments

More information

Fractions. Dividing the numerator and denominator by the highest common element (or number) in them, we get the fraction in its lowest form.

Fractions. Dividing the numerator and denominator by the highest common element (or number) in them, we get the fraction in its lowest form. Fractions A fraction is a part of the whole (object, thing, region). It forms the part of basic aptitude of a person to have and idea of the parts of a population, group or territory. Civil servants must

More information

CMSC 331 Final Exam Fall 2013

CMSC 331 Final Exam Fall 2013 CMSC 331 Final Exam Fall 2013 Name: UMBC username: You have two hours to complete this closed book exam. Use the backs of these pages if you need more room for your answers. Describe any assumptions you

More information

Sequence Analysis with Perl. Unix, Perl and BioPerl. Why Perl? Objectives. A first Perl program. Perl Input/Output. II: Sequence Analysis with Perl

Sequence Analysis with Perl. Unix, Perl and BioPerl. Why Perl? Objectives. A first Perl program. Perl Input/Output. II: Sequence Analysis with Perl Sequence Analysis with Perl Unix, Perl and BioPerl II: Sequence Analysis with Perl George Bell, Ph.D. WIBR Bioinformatics and Research Computing Introduction Input/output Variables Functions Control structures

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine

More information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides

More information

BIOS 546 Midterm March 26, Write the line of code that all Perl programs on biolinx must start with so they can be executed.

BIOS 546 Midterm March 26, Write the line of code that all Perl programs on biolinx must start with so they can be executed. 1. What values are false in Perl? BIOS 546 Midterm March 26, 2007 2. Write the line of code that all Perl programs on biolinx must start with so they can be executed. 3. How do you make a comment in Perl?

More information

While Statement Examples. While Statement (35.15) Until Statement (35.15) Until Statement Example

While Statement Examples. While Statement (35.15) Until Statement (35.15) Until Statement Example While Statement (35.15) General form. The commands in the loop are performed while the condition is true. while condition one-or-more-commands While Statement Examples # process commands until a stop is

More information

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto CS 170 Java Programming 1 Expressions Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 What is an expression? Expression Vocabulary Any combination of operators and operands which, when

More information

Essentials for Scientific Computing: Bash Shell Scripting Day 3

Essentials for Scientific Computing: Bash Shell Scripting Day 3 Essentials for Scientific Computing: Bash Shell Scripting Day 3 Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Introduction In the previous sessions, you have been using basic commands in the shell. The bash

More information

Unix, Perl and BioPerl

Unix, Perl and BioPerl Unix, Perl and BioPerl II: Sequence Analysis with Perl George Bell, Ph.D. WIBR Bioinformatics and Research Computing Sequence Analysis with Perl Introduction Input/output Variables Functions Control structures

More information

CSE 341 Section Handout #6 Cheat Sheet

CSE 341 Section Handout #6 Cheat Sheet Cheat Sheet Types numbers: integers (3, 802), reals (3.4), rationals (3/4), complex (2+3.4i) symbols: x, y, hello, r2d2 booleans: #t, #f strings: "hello", "how are you?" lists: (list 3 4 5) (list 98.5

More information

Perl for Biologists. Regular Expressions. Session 7. Jon Zhang. April 23, Session 7: Regular Expressions CBSU Perl for Biologists 1.

Perl for Biologists. Regular Expressions. Session 7. Jon Zhang. April 23, Session 7: Regular Expressions CBSU Perl for Biologists 1. Perl for Biologists Session 7 April 23, 2014 Regular Expressions Jon Zhang Session 7: Regular Expressions CBSU Perl for Biologists 1.1 1 Review of Session 6 Each program has three default input/output

More information

Perl for Biologists. Session 9 April 29, Subroutines and functions. Jaroslaw Pillardy

Perl for Biologists. Session 9 April 29, Subroutines and functions. Jaroslaw Pillardy Perl for Biologists Session 9 April 29, 2015 Subroutines and functions Jaroslaw Pillardy Perl for Biologists 1.2 1 Suggestions Welcomed! There are three more sessions devoted to practical examples They

More information

example: name1=jan name2=mike export name1 In this example, name1 is an environmental variable while name2 is a local variable.

example: name1=jan name2=mike export name1 In this example, name1 is an environmental variable while name2 is a local variable. Bourne Shell Programming Variables - creating and assigning variables Bourne shell use the set and unset to create and assign values to variables or typing the variable name, an equal sign and the value

More information

8/13/ /printqp.php?heading=II BSc [ ], Semester III, Allied: COMPUTER PROGRAMMING-PERL -309C&qname=309C

8/13/ /printqp.php?heading=II BSc [ ], Semester III, Allied: COMPUTER PROGRAMMING-PERL -309C&qname=309C Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated 'A'

More information

Chapter 3 Problem Solving and the Computer

Chapter 3 Problem Solving and the Computer Chapter 3 Problem Solving and the Computer An algorithm is a step-by-step operations that the CPU must execute in order to solve a problem, or to perform that task. A program is the specification of an

More information

Name: Date: Review Packet: Unit 1 The Number System

Name: Date: Review Packet: Unit 1 The Number System Name: Date: Math 7 Ms. Conway Review Packet: Unit 1 The Number System Key Concepts Module 1: Adding and Subtracting Integers 7.NS.1, 7.NS.1a, 7.NS.1b, 7.NS.1c, 7.NS.1d, 7.NS.3, 7.EE.3 To add integers with

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. 1992-2010 by Pearson Education, Inc. 1992-2010 by Pearson Education, Inc. This chapter serves as an introduction to the important topic of data

More information

REVIEW. The C++ Programming Language. CS 151 Review #2

REVIEW. The C++ Programming Language. CS 151 Review #2 REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,

More information

Example 2: Simplify each of the following. Round your answer to the nearest hundredth. a

Example 2: Simplify each of the following. Round your answer to the nearest hundredth. a Section 5.4 Division with Decimals 1. Dividing by a Whole Number: To divide a decimal number by a whole number Divide as you would if the decimal point was not there. If the decimal number has digits after

More information

Objectivities. Experiment 1. Lab6 Array I. Description of the Problem. Problem-Solving Tips

Objectivities. Experiment 1. Lab6 Array I. Description of the Problem. Problem-Solving Tips Lab6 Array I Objectivities 1. Using rand to generate random numbers and using srand to seed the random-number generator. 2. Declaring, initializing and referencing arrays. 3. The follow-up questions and

More information

A control expression must evaluate to a value that can be interpreted as true or false.

A control expression must evaluate to a value that can be interpreted as true or false. Control Statements Control Expressions A control expression must evaluate to a value that can be interpreted as true or false. How a control statement behaves depends on the value of its control expression.

More information

MATH LEVEL 2 LESSON PLAN 5 DECIMAL FRACTIONS Copyright Vinay Agarwala, Checked: 1/22/18

MATH LEVEL 2 LESSON PLAN 5 DECIMAL FRACTIONS Copyright Vinay Agarwala, Checked: 1/22/18 Section 1: The Decimal Number MATH LEVEL 2 LESSON PLAN 5 DECIMAL FRACTIONS 2018 Copyright Vinay Agarwala, Checked: 1/22/18 1. The word DECIMAL comes from a Latin word, which means "ten. The Decimal system

More information

For Module 2 SKILLS CHECKLIST. Fraction Notation. George Hartas, MS. Educational Assistant for Mathematics Remediation MAT 025 Instructor

For Module 2 SKILLS CHECKLIST. Fraction Notation. George Hartas, MS. Educational Assistant for Mathematics Remediation MAT 025 Instructor Last Updated: // SKILLS CHECKLIST For Module Fraction Notation By George Hartas, MS Educational Assistant for Mathematics Remediation MAT 0 Instructor Assignment, Section. Divisibility SKILL: Determine

More information

COP Programming Assignment #7

COP Programming Assignment #7 1 of 5 03/13/07 12:36 COP 3330 - Programming Assignment #7 Due: Mon, Nov 21 (revised) Objective: Upon completion of this program, you should gain experience with operator overloading, as well as further

More information

INDIAN SCHOOL MUSCAT COMPUTER SCIENCE(083) CLASS XI

INDIAN SCHOOL MUSCAT COMPUTER SCIENCE(083) CLASS XI INDIAN SCHOOL MUSCAT COMPUTER SCIENCE(083) CLASS XI 2017-2018 Worksheet No. 1 Topic : Getting Started With C++ 1. Write a program to generate the following output: Year Profit% 2011 18 2012 27 2013 32

More information

Lecture 5. Essential skills for bioinformatics: Unix/Linux

Lecture 5. Essential skills for bioinformatics: Unix/Linux Lecture 5 Essential skills for bioinformatics: Unix/Linux UNIX DATA TOOLS Text processing with awk We have illustrated two ways awk can come in handy: Filtering data using rules that can combine regular

More information

The Power of Perl. Perl. Perl. Change all gopher to World Wide Web in a single command

The Power of Perl. Perl. Perl. Change all gopher to World Wide Web in a single command The Power of Perl Perl Change all gopher to World Wide Web in a single command perl -e s/gopher/world Wide Web/gi -p -i.bak *.html Perl can be used as a command Or like an interpreter UVic SEng 265 Daniel

More information

Any Integer Can Be Written as a Fraction

Any Integer Can Be Written as a Fraction All fractions have three parts: a numerator, a denominator, and a division symbol. In the simple fraction, the numerator and the denominator are integers. Eample 1: Find the numerator, denominator, and

More information

1. Introduction. 2. Scalar Data

1. Introduction. 2. Scalar Data 1. Introduction What Does Perl Stand For? Why Did Larry Create Perl? Why Didn t Larry Just Use Some Other Language? Is Perl Easy or Hard? How Did Perl Get to Be So Popular? What s Happening with Perl Now?

More information

Spoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03

Spoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03 CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS Spoke Language Reference Manual* William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03 (yw2347, ct2459, zy2147, xc2180)@columbia.edu Columbia University,

More information

Andrew Shitov. Using Perl Programming Challenges Solved with the Perl 6 Programming Language

Andrew Shitov. Using Perl Programming Challenges Solved with the Perl 6 Programming Language Andrew Shitov Using Perl 6 100 Programming Challenges Solved with the Perl 6 Programming Language DeepText 2017 Using Perl 6 100 Programming Challenges Solved with the Perl 6 Programming Language Andrew

More information

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++

Chapter 5. Repetition. Contents. Introduction. Three Types of Program Control. Two Types of Repetition. Three Syntax Structures for Looping in C++ Repetition Contents 1 Repetition 1.1 Introduction 1.2 Three Types of Program Control Chapter 5 Introduction 1.3 Two Types of Repetition 1.4 Three Structures for Looping in C++ 1.5 The while Control Structure

More information

CSCI 4152/6509 Natural Language Processing. Perl Tutorial CSCI 4152/6509. CSCI 4152/6509, Perl Tutorial 1

CSCI 4152/6509 Natural Language Processing. Perl Tutorial CSCI 4152/6509. CSCI 4152/6509, Perl Tutorial 1 CSCI 4152/6509 Natural Language Processing Perl Tutorial CSCI 4152/6509 Vlado Kešelj CSCI 4152/6509, Perl Tutorial 1 created in 1987 by Larry Wall About Perl interpreted language, with just-in-time semi-compilation

More information

Excerpt from "Art of Problem Solving Volume 1: the Basics" 2014 AoPS Inc.

Excerpt from Art of Problem Solving Volume 1: the Basics 2014 AoPS Inc. Chapter 5 Using the Integers In spite of their being a rather restricted class of numbers, the integers have a lot of interesting properties and uses. Math which involves the properties of integers is

More information

UNIX Shell Programming

UNIX Shell Programming $!... 5:13 $$ and $!... 5:13.profile File... 7:4 /etc/bashrc... 10:13 /etc/profile... 10:12 /etc/profile File... 7:5 ~/.bash_login... 10:15 ~/.bash_logout... 10:18 ~/.bash_profile... 10:14 ~/.bashrc...

More information

Perl Scripting. Students Will Learn. Course Description. Duration: 4 Days. Price: $2295

Perl Scripting. Students Will Learn. Course Description. Duration: 4 Days. Price: $2295 Perl Scripting Duration: 4 Days Price: $2295 Discounts: We offer multiple discount options. Click here for more info. Delivery Options: Attend face-to-face in the classroom, remote-live or on-demand streaming.

More information

Systems Skills in C and Unix

Systems Skills in C and Unix 15-123 Systems Skills in C and Unix Plan Perl programming basics Operators loops, arrays, conditionals file processing subroutines, references Systems programming Command line arguments Perl intro Unix

More information

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related?

1. Let n be a positive number. a. When we divide a decimal number, n, by 10, how are the numeral and the quotient related? Black Converting between Fractions and Decimals Unit Number Patterns and Fractions. Let n be a positive number. When we divide a decimal number, n, by 0, how are the numeral and the quotient related?.

More information

CSC 533: Programming Languages. Spring 2015

CSC 533: Programming Languages. Spring 2015 CSC 533: Programming Languages Spring 2015 Functional programming LISP & Scheme S-expressions: atoms, lists functional expressions, evaluation, define primitive functions: arithmetic, predicate, symbolic,

More information

2.5 Another Application: Adding Integers

2.5 Another Application: Adding Integers 2.5 Another Application: Adding Integers 47 Lines 9 10 represent only one statement. Java allows large statements to be split over many lines. We indent line 10 to indicate that it s a continuation of

More information

Introduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi

Introduction Variables Helper commands Control Flow Constructs Basic Plumbing. Bash Scripting. Alessandro Barenghi Bash Scripting Alessandro Barenghi Dipartimento di Elettronica, Informazione e Bioingegneria Politecnico di Milano alessandro.barenghi - at - polimi.it April 28, 2015 Introduction The bash command shell

More information

Shell Programming Overview

Shell Programming Overview Overview Shell programming is a way of taking several command line instructions that you would use in a Unix command prompt and incorporating them into one program. There are many versions of Unix. Some

More information

Perl for Biologists. Arrays and lists. Session 4 April 2, Jaroslaw Pillardy. Session 4: Arrays and lists Perl for Biologists 1.

Perl for Biologists. Arrays and lists. Session 4 April 2, Jaroslaw Pillardy. Session 4: Arrays and lists Perl for Biologists 1. Perl for Biologists Session 4 April 2, 2014 Arrays and lists Jaroslaw Pillardy Session 4: Arrays and lists Perl for Biologists 1.1 1 if statement if(condition1) statement; elsif(condition2) statement;

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Learning Log Title: CHAPTER 3: ARITHMETIC PROPERTIES. Date: Lesson: Chapter 3: Arithmetic Properties

Learning Log Title: CHAPTER 3: ARITHMETIC PROPERTIES. Date: Lesson: Chapter 3: Arithmetic Properties Chapter 3: Arithmetic Properties CHAPTER 3: ARITHMETIC PROPERTIES Date: Lesson: Learning Log Title: Date: Lesson: Learning Log Title: Chapter 3: Arithmetic Properties Date: Lesson: Learning Log Title:

More information

Shell Programming (Part 2)

Shell Programming (Part 2) i i Systems and Internet Infrastructure Security Institute for Networking and Security Research Department of Computer Science and Engineering Pennsylvania State University, University Park, PA Shell Programming

More information

Bash scripting basics

Bash scripting basics Bash scripting basics prepared by Anatoliy Antonov for ESSReS community September 2012 1 Outline Definitions Foundations Flow control References and exercises 2 Definitions 3 Definitions Script - [small]

More information

Oct Decision Structures cont d

Oct Decision Structures cont d Oct. 29 - Decision Structures cont d Programming Style and the if Statement Even though an if statement usually spans more than one line, it is really one statement. For instance, the following if statements

More information

MA 1128: Lecture 02 1/22/2018

MA 1128: Lecture 02 1/22/2018 MA 1128: Lecture 02 1/22/2018 Exponents Scientific Notation 1 Exponents Exponents are used to indicate how many copies of a number are to be multiplied together. For example, I like to deal with the signs

More information

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects: Numeral Systems -Numeral System -Positional systems -Decimal -Binary -Octal Subjects: Introduction A numeral system (or system of numeration) is a writing system for expressing numbers, that is a mathematical

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

Conversion Between Number Bases

Conversion Between Number Bases Conversion Between Number Bases MATH 100 Survey of Mathematical Ideas J. Robert Buchanan Department of Mathematics Summer 2018 General Number Bases Bases other than 10 are sometimes used in numeration

More information

CS160A EXERCISES-FILTERS2 Boyd

CS160A EXERCISES-FILTERS2 Boyd Exercises-Filters2 In this exercise we will practice with the Unix filters cut, and tr. We will also practice using paste, even though, strictly speaking, it is not a filter. In addition, we will expand

More information