1 / 7

Variables, Arrays, and Hashes in Perl

Variables, Arrays, and Hashes in Perl. Variables. Login to unixs.cis.pitt.edu and create a hello.pl which will print "hello world“

silas
Download Presentation

Variables, Arrays, and Hashes in Perl

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Variables, Arrays, and Hashesin Perl

  2. Variables • Login to unixs.cis.pitt.edu and create a hello.pl which will print "hello world“ • Variables: Instantiate 4 variables. Begin by assigning them values. Print the sum, product, and difference of the 4 variables. Then assign strings as values to the variables and print a nice story.

  3. Variables • perl –w xxx.pl • Or add #!/bin/perl –w in the first line of perl • @,$

  4. Array • Construct an array consisting of 3 of your favorite baseball teams. • Then, incorporate this array into a larger array of your favorite teams overall. Use the length of the new array to print each element in the array. • Then, print only the first, third, and last element. To this array, add elements to the beginning and to the end. • Then, remove them from the beginning and the end. • Finally, sort the array both forward and backward.

  5. Array • qw • [-1] • for/foreach • push,unshift,shift,pop • sort/reverse sort • http://raleigh.pm.org/sorting.html

  6. Hashes • Construct a hash that maps several Universities to their shortened names, i.e. Pittsburgh to Pitt. • Sort and print the hash, and then reverse sort and print the hash.

  7. Hash • % • delete

More Related