in reply to Iterating Through a Hash and Emailing the Result

bivouac,
You were almost there. You have a couple of issues. Try the following instead:
#!/usr/bin/perl use strict; use warnings; use Mail::Mailer; my %hash = (foo => '3.14159265358', bar => '1.61803398874'); notify( \%hash ); sub notify { my $hash_ref = shift; my $mailer = Mail::Mailer->new("sendmail"); $mailer->open( { From => 'system@system.com', To => 'me@system.com', Subject => 'Warning', } ) or die "Can't open sendmail : $!"; for my $key ( keys %{ $hash_ref ) ) { print $mailer "$key : $hash_ref->{$key}\n"; } $mailer->close(); }
Cheers - L~R

Replies are listed 'Best First'.
Re: Re: Iterating Through a Hash and Emailing the Result
by bivouac (Beadle) on Mar 25, 2004 at 14:48 UTC
    Thanks so much. I couldn't figure out where to put that "for" block in the "mail" part. Unblocked!