Greetings!
I've found this question before but I'm no understanding the process to completing this successfully.
My problem is this... take a look at http://www.disksleeves.com/, choose a letter of sleeves to look at and then pick a sleeve... if you keep going forwards or backwards to the next or previous sleeve, you'll see what's happening...
The image of an old sleeve is shown before the new one pops up HOWEVER the script has the command to show the .GIF being written AFTER the write command...
naturally, this is apparently a common problem yet I can't solve it. Wait doesn't work. FLOCK doesn't do anything - etc...
The code is basically:
---
$newimage->copyMerge($watermark, 30, 165, 0, 0, 350, 80, 15);
$maxtotal = 30;
$totalnum = 0;
open (xx,"<$cascade");
@totalnum = <xx>;
close (xx);
$totalnum = @totalnum[0];
$totalnum ++;
if ($totalnum > $maxtotal) {
$totalnum = 0;
}
open (xx, ">$cascade") or die("Cannot open file for writing");
print xx "$totalnum\n";
close (xx);
$temppic = "/home/u4/dat3/html/dsa/temppics/$totalnum.gif";
open(PICTURE,">$temppic") or die("Cannot open file for writing");
flock(PICTURE, LOCK_EX);
binmode PICTURE;
print PICTURE $newimage->gif;
close PICTURE;
print "<img src=\"/dsa/temppics/$totalnum.gif\" width=\"400\">
\n\n";
So natually, between "close PICTURE;" and the next "print "<img src=..."" line, there needs to be a way to delay until the CLOSE actually CLOSES!
Unfortunately, FLOCK didn't work - I did it and still I got the quick flash of the previously stored sleeve...
NOW I've also tried to bypass the writing of a temp file altogether and spit the gif output directly to the screen but I can't get that to work as every attempt simply spits the ASCII of the gif out, even with BINMODE yet I can do it on it's own in a test .pl file - The difference there is that the test file is just spitting out the image - nothing else where as this already has html spit out and changing the content: to gif doesn't work like it does in my stand along test file.
OK - hopefully this made sense!
Thanks
Peter
I would rather just do that and have no
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.