Exercise 1 & 2 for perl