Hello all. I am not sure if this is the correct place to post this, but I am having a problem with some code and I have absolutely no idea why. It is intended to generate four different images, each a different quarter of a circle. It was mostly just for experimentation. When I run it, using perl 5.005 or MacPerl, I get a segmentation fault. There is probably a more efficient way to do this, but could anyone help fix it?
#!/usr/bin/perl -w
use strict;
use GD;
my (%arcData,$orientation,$white,$black,$red,@insertData,$img);
%arcData=(topRight=>'0,25,50,50,270,360',
topLeft=>'25,25,50,50,180,270',
bottomRight=>'0,0,50,50,0,90',
bottomLeft=>'25,0,50,50,90,180');
foreach $orientation (keys(%arcData)) {
@insertData=split(/,/,$arcData{$orientation});
$img=new GD::Image(25,25);
$white=$img->colorAllocate(255,255,255);
$img->transparent($white);
$black=$img->colorAllocate(0,0,0);
$img->arc(@insertData,$black);
$red=$img->colorAllocate(255,0,0);
$img->fill(@insertData[0,1],$red);
open (IMAGEOUT,">$orientation.gif")||die("can't write to $orientat
+ion.gif: $!");
binmode (IMAGEOUT);
print IMAGEOUT $$orientation->gif;
close (IMAGEOUT);
print "wrote $orientation.gif.\n";
}
That's all. Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.