# Let's see how much money I would have if I just won the # lottery and found a 2 pound coin in the couch cushions... How many 5 pence pieces do you have? 0 How many 10 pence pieces do you have? 0 How many 20 pence pieces do you have? 0 How many 50 pence pieces do you have? 0 How many £1 coins do you have? 1000000000 How many £2 coins do you have? 1 How many £5 notes do you have? 0 How many £10 notes do you have? 0 How many £20 notes do you have? 0 How many £50 notes do you have? 0 You have £2. # Hmm, guess I won't spend my £2 on a lottery ticket then... #### #!/usr/bin/perl -w use strict; use warnings; use List::Util qw( sum ); printf( "You have £%.02f\n", sum ( ( map { ask( "$_ pence pieces", $_/100 ) } ( 5, 10, 20, 50 ) ), ( map { ask( "£$_ coins", $_ ) } ( 1, 2 ) ), ( map { ask( "£$_ notes", $_ ) } ( 5, 10, 20, 50 ) ), ) ); sub ask { print "How many $_[0] do you have? " ; * $_[1] }