When learning a programming language, the most important thing is to practice. Here are some exercises you can do. At first I am going to follow the Perl programming course I have been teaching for many years, but of course these exercises can be solved in many other languages.

Introduction

  1. Hello World (print, documentation, comments)

Scalars

  1. Calculate Area of Rectangular (Standard I/O, if)
  2. Number guessing game (random, prompt, if)
  3. Create calculator

Files

  1. Sum of numbers in a file (open, loop +=)
  2. Analyze Apache log file (count localhost vs others, index, substr)
  3. Add more statistics
  4. Write report to file

Lists and Arrays

  1. Color selector
  2. Add numbers taken from CSV file
  3. Improve the color selector
  4. Improve number guessing game
  5. Count digits
  6. Sort based on secondary condition
  7. Display unique rows of a file
  8. Sort mixed strings
  9. Queue at the Doctor
  10. Check if number is prime
  11. Reverse Polish Calculator

Hashes, Dictionaries

  1. Count words in a file
  2. Parse HTTP GET parameters
  3. Sort scores
  4. Analyze Apache log file (count all the hits from all the clients)
  5. Parse file with variable width fields

Functions and Subroutines

  1. Implement ROT13

Regular Expressions, Regexes

  1. Regex Exercises - part 1
  2. Match numbers with regex
  3. Match hexa, octal, binary numbers
  4. Match Roman numbers
  5. Split file path with regex
  6. Sort SNMP numbers
  7. Parse hours log file and create time report
  8. Parse INI or Config files.

Linux

  1. Linux as a Virtual Environment - install + nginx

Shell

3rd party libraries

  1. Install Module from CPAN/PyPi/Gems/etc.

Simple applications

  1. Exercise: Implement the wc command of Linux/Unix (word count)
  2. Traverse directory implementing du
  3. One dimensional spacefight (aka. The spaceship operator)
  4. MasterMind

Mix

  1. Send plain text e-mail
  2. Send HTML e-mail
  3. Send e-mail with attachments
  4. Compare Wikipedia translations

Web development

  1. Hello World
  2. Echo in a web application
  3. Personal Bookmarks
  4. URL Shortener
  5. TODO list
  6. Flight ticket vendor

Web crawlers

  1. Download a web page, fetch a URL
  2. TED

Perl specific exercises