Je55eah has asked for the wisdom of the Perl Monks concerning the following question:
*HASH(0x37fc4)$
That is the unexpected result that I gaet from the following code. Why is it making a hash? What I really want is a big string that is formatted as a easy to read list. Thank you,
# Begin %admin_expenses = { 'President' => 60000, 'Vice President' => 50000, 'Engineer' => 50000, 'House Keeper' => 50000, '6 Part Time Attendants' => 120000, '12 Interns' => 12000, 'Contractor' => 50000, 'Hired Professionals' => 60000, 'Lawyers' => 60000, 'Law Student' => 40000, 'Nurse' => 60000, 'Facility + Utilities' => 40000, 'Truck' => 40000, 'Forklift' => 20000, 'Driver / Contractor' => 70000, 'Phone Attendant' => 30000, 'pallets, packaging, and office supplies' => 60000 }; while(($expense, $amount) = each %admin_expenses) { $total_admin_expenses = $total_admin_expenses + $amount; $adminExpenses .= '*' . $expense . '$' . add_commas($amount) . "\n +"; } $ $adminExpenses = "###Admin Expenses = \n" . $adminExpenses; print $adminExpenses; sub add_commas { my $number = reverse $_[0]; $number =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $number; } # End
|
|---|