#!/usr/bin/perl use strict; use warnings; sub pence { my ($coin) = @_; print "How many $coin pence pieces do you have? "; chomp( my $num= ); return ($coin * $num)/100; } sub coins { my ($coin) = @_; print "How many £$coin coins do you have? "; chomp( my $num= ); return ($coin * $num); } sub notes { my ($note) = @_; print "How many £$note notes do you have? "; chomp( my $num= ); return ($note * $num); } { my $total = 0; $total += pence($_) for 5, 10, 20, 50; $total += coins($_) for 1, 2; $total += notes($_) for 5, 10, 20, 50; print "You have £$total.\n"; }