Hi All. I need some help with the below. The script works fine except that for most recipients or mailers/clients the strings of text so not alternate with the image files. In their mailers they see:
Number of users logged-in for kaplanfinancial: Number of users logged-in for brunswick: Number of users logged-in for bioera: Number of users logged-in for alpharma: Number of users logged-in for apogee: Followed by the png files I prolly need to be using HTML, right? Thanks for any help. #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use MIME::Lite; use Data::Dumper; my %managers; # read in data # DATA is a "file handle" open DATA, "<testdata"; while (my $line = <DATA>) { # one way to do a condition if ($line =~ /^$/) { next; } my @firms = split /\s+/, $line; my $manager = shift @firms; foreach my $firm (@firms) { push @{$managers{$manager}{accounts}}, $firm; # Above is the managers hash, inside that hash there is a key per manager. # when you ask for a manager you get a reference to a hash-- # that hash has an accounts key. We can add more keys later if we want. # ex: manager name, manager cranium size, etc. # when you ask for the accounts key you get a list of accounts. # a list is an array and vice versa. We have the @{ } so that perl knows # that we are talking about an array because it wouldn't necesarrily otherwise. } } close DATA; foreach my $manager (keys %managers) { # Create a new multipart message: my $msg = MIME::Lite->new( "From" => "[EMAIL PROTECTED]", "To" => $manager, "Cc" => "[EMAIL PROTECTED]", "Subject" => "This week's usage data...", "Type" => "multipart/mixed" ); foreach my $firm (@{$managers{$manager}{accounts}}) { my $agent = LWP::UserAgent->new; $agent->agent("UsageMonitor/0.1 "); my $req = HTTP::Request->new(GET => "http://steering.com/cricket/grapher.cgi?type=png;target=%2FPSHome-Data%2F${firm};dslist=Logged-In;range=604800;rand=951"); $req->content_type('image/png'); my $response = $agent->request($req); unless ($response->is_success) { print "it broke.\n"; exit 1; } # Add parts (each "attach" has same arguments as "new"): $msg->inline("Type" => "TEXT", "Data" => "Number of users logged-in for $firm: \n" ); $msg->attach("Type" => "image/png", "Data" => $response->content, "Filename" => "${firm}.png", "Disposition" => "attachment" ); } $msg->send; } -- Ubuntu eh? I'm not really into Pokemon. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/