You can open() a program to write to it, or open() a program to read from it, but to do both you'll need to take extra steps. You're trying to do both, so you'll need to look for alternatives. One possibility (untested) is to try something like:
open(ARGS, ">args$$") or die "args$$: $!";
print ARGS <<ENDARGS;
new
size 256,256
... etc
ENDARGS
close(ARGS);
open(FLY, "$flyprog -f args$$ |") or die "$flyprog: $!";
binmode(STDOUT);
print "Content-type: image/png\n\n";
print <FLY>;
close(FLY);
unlink("args$$");
In this approach, you write the commands to fly out to a temporary file, then feed that file back to fly via the "command line" that you're opening. (I'm assuming that there's way to pass a filename to fly.)
The output, which you read from the command, is the PNG.
Depending on your server configuration, you might need to put the temporary "args" file somewhere else, like /tmp
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.