|
|
HomeNewsExamplesDemoDownloadsFAQDocumentationMailing ListsLicense
|
8:43 am GMT
GeSHi - Generic Syntax Highlighter
Latest News
News Archive
|
Random Screenshot
Demonstration
Runtime Example
use strict 'vars';
my %total;
while (<>) {
my ($who, $action, $how_much) = split;
unless ($how_much =~ /^\d+\.\d\d$/) {
die "Malformed amount field";
}
if ($action eq 'deposit') { $total{$who} += $how_much }
elsif ($action eq 'withdraw') { $total{$who} -= $how_much }
else { die "Bizarre action field `$action'" }
}
for my $customer (sort keys %total) {
print "$customer:\t$total{$customer}.\n";
}
|
|