Popular in Course
Popular in ComputerScienence
This 8 page Class Notes was uploaded by Jonas Bartell on Monday October 26, 2015. The Class Notes belongs to CS1555 at University of Pittsburgh taught by PanosChrysanthis in Fall. Since its upload, it has received 90 views. For similar materials see /class/229382/cs1555-university-of-pittsburgh in ComputerScienence at University of Pittsburgh.
Reviews for DATABASEMANAGEMENTSYSTEMSRECITATION
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 10/26/15
CS 1520 Fall 2005 Programming Languages for Web Applications 05 Perl cont Alexandros Labrinidis University of Pittsburgh How to run Perl programs revised Use text editor say pico to write and save program say hellop Option 1 perl w hellop1 Next time perl w hellopl Option 2 Make sure first line of hellop is the following binperl chmod ux hello p1 hello p1 Next time hellopl Aiexandros Labrinidis Univ 0 Pittsburgh 2 CS 1520 EH 2005 I ListsArraysSlices recap Assignment LHS vs RHS beniffer ben affleck jennifer lopez beniffer1 jennifer gardner fred barney 14 25 a b b a Scalar vs List context a beniffer print a n print bennifer n Alexandros Labiinidis Univ 0 Pittsburgh 3 CS 1520 all2005 I ListsArraysSlices Push Pop Push to right end of array Adds an element to end of list Iist 2 4 6 push Iist 5 Iist now 2 4 6 5 Push Iist 3 10 Iist now 2 4 6 5 3 10 Pop from right end of array Removes the last element of a list I P P0P Iist p becomes 10 I Iist now 2 4 6 5 3 Alexandros Labrinidis Univ 0 Pittsburgn 4 CS 1520 all 2005 I ListsArraysSlices ShiftUnshift Unshift to left end of array Adds an element to the beginning of list list 2 4 6 unshift list 7 list now 7 2 4 6 unshift list 1 12 list now 1 12 7 2 4 6 Shift from left end of array Removes the rst element of a list p shift list p becomes 1 list now 12 7 2 4 6 Alexandros Labiinidis Univ 0 Pittsburgh 5 CS 1520 all 2005 I ListsArraysSlices Sort Reverse I Sort sorts elements of an array Example x qwsma medium large y sort x X stays the same y is large medium small Reverse Reverses current order ie NOT the reverse sort order a 10 5 12 45 b reverse a a stays the same b is 45 12 5 10 Alexandros Labrinidis Univ 0 Pittsburgh 6 CS 1520 all 2005 il Control Structures ifthen if else if a gt 5 do nothing else a unless Unless agt5 I Alexandros Labnnldls Univ 0 Pittsburgh 7 CS 1520 all 2005 i Control Structures while while loop while a gt 5 do something until until a lt 5 a Alexandros Labnnldls Univ 0 Pittsburgh 8 CS 1520 all 2005 I Control Structures dowhile dowhile loop do do something while a gt 5 dountil loop do do something until a lt 5 Alexandros Labnnldls Univ 0 Pittsburgh 9 CS 1520 all2005 I InputOutput Output print simple printf formatted version Input standard input is accessed via ltSTDINgt will return 0 if no more input ltgt form is more general can read from files to access line within loop while ltSTDINgt print Alexandros Labnnldls Univ 0 Pittsburgh 10 CS 1520 all 2005 I Inputcon0 Scalar versus List context a ltSTDINgt reads next line of input b ltSTDINgt reads all lines at once Useful string functions lengthstr returns length of string uc converts to upper case lc converts to lower case chompstr removes trailing n Alexandros Labrinidis Univ 0 Pittsburgh 11 CS 1520 all 2005 I Hashes Arrays are nice index is always numeric Q Would it not be nice to access arrays using strings A Yes A using Hashes ooclass is a hash Initialization ciass cs1520quot SENSQ 5502quot cass cs1520quot gt SENSQ 5502quot cs1555 gt SENSQ 5502quot cass cs1520quot SENSQ 5502quot cs1555 SENSQ 5502quot Alexandros Labrinidis Univ 0 Pittsburgh 12 CS 1520 all 2005 I Hash Functions keys lohashname return the list of current keys fred a b fred c d fred15 143 list keysfred list a c 15 n keysfred n 3 foreach k keys fred print we have fredk at key kn values lohashname Alexandros Labnnidis Univ 0 Pittsburgh 13 CS 1520 all2005 I Hash functions cont each hashname Iterate over all elements of hash hashname lastname Alex Labrinidis lastname Panos Chrysanthis lastname John Ramirez while first last each lastname print The last name of first is lastn delete delete lastname Panos Alexandros Labnnidis Univ 0 Pittsburgh 14 CS 1520 all 2005 i Regular Expressions intro grep abc some le gt results while ltgt if abc print Alexandros Labnnldls Unlv O Plttsburgh 15 CS 1520 all 2005
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'