graph problem


S

Sokar

Hello,

I have a script which creates a pie chart from the following lines of code:

my @values = (["$val1", "$val2", "$val3", "$val4"],
[$var1, $var2, $var3, $var4]);

my $graph = GD::Graph::pie->new(300, 300);
$graph->set(
title => "Status of students for
year: $year",
'3d' => 1,
) or warn $graph->error;

my $image = $graph->plot(\@values) or die "cant print graph\n";

open(IMG, ">pie1.jpeg") or die $!;
binmode IMG;
print $image->jpeg;
close IMG;

This bit of code actually creates a jpeg and stores it on the hard drive.
What I am looking to do is actually create the graph and then e-mail it to a
person. I was wondering if anyone knew how I could maybe instead of writing
the graph into an actual jpeg, write it into a variable and then e-mail the
variable as a jpeg to an e-mail address, to save me having the created jpegs
sitting on my hard drive.

Thanks and regards

John
 
Ad

Advertisements

O

Octo Mancer

On Tue, 22 Mar 2005 14:43:40 +0000, Sokar wrote:

open(IMG, ">pie1.jpeg") or die $!;
binmode IMG;
print $image->jpeg;

ITYM

print IMG $image->jpeg;
close IMG;

This bit of code actually creates a jpeg and stores it on the hard drive.
What I am looking to do is actually create the graph and then e-mail it to
a person. I was wondering if anyone knew how I could maybe instead of
writing the graph into an actual jpeg, write it into a variable and then
e-mail the variable as a jpeg to an e-mail address, to save me having the
created jpegs sitting on my hard drive.

Use IO::Scalar (code untested):

my $img;
my $imgScalar = IO::Scalar->new(\$img);
print $imgScalar $image->jpeg;

HTH
Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top