Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Softpanorama Search

Introduction to Perl for Unix System Administrators

(Perl without excessive complexity)

by Dr Nikolai Bezroukov


Prev | Up | Contents | Down | Next

3.5. Homework

  1. Name what string functions affect the content of  $_ variable?
  2. what string functions accept $_ variable as default argument?
  3. Execute the following fragment in the debugger and see what splice function will return in this particular case. I bet you will be surprised ;-) to see the result printed.

    splice(@week, $#week);

    splice(@week,-2);

    print "@week \n";

  4. Write a program that reverses a string using the chop() function. Print both the initial string and the result. 
  5. Write a function that uses the substr() and uc() functions to change each second character of the string to upper case (can be useful for generating passwords).
  6. Write a program that uses the keys() function to convert all keys of an associative array into the uppercase strings.
  7. Write a program that can be used to teach the user what the shift() and unshift() functions do.
  8. Write a program that can be used to teach what the push() and pop() functions do.
  9. *(see Perl documentation) What does the map() function do?

Prev | Up | Contents | Down | Next



Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Disclaimer:

Created: November 7 1998; Last modified: September 04, 2009