in reply to Random Change for a Dollar

A couple minor comments.

First, separate the dynamic data from the static data. You have a nice little structure to define the coins, but you also store the counters in that same structure. This means you have to create or clear that definition table before every transaction. Keep them separate.

Second, you're "humanizing" the output with names like quarter and nickel. So finish the job and get rid of that canned mechanical "penny(s)" wording, and don't mention the coins that are not counted. (Not tested.)

foreach (@coins) { next if not $_->{counter}; my $name = (1==$_->{counter})? $_->{name} : ($_->{plural} || $_->{name}.'s'); print $_->{counter}, " ", $name, "\n"; }
Threading it into a sentence instead of a columnar list is left as an exercise.

--
[ e d @ h a l l e y . c c ]