I've read the buffering FAQs and I've peppered my code with '$| = 1;'and STDOUT->flush(); , tried STDOUT->autoflush(1); but since moving from a RHEL5 (perl 5.8.8) to RHEL6 (perl 5.10.1) this script (simplified from original, but still exhibits the problem) doesn't write out all the binary image data to STDOUT before the last line is written - the last line appears in the middle of the binary data about 150 bytes from the end.
Help!
ImageMagick-perl has gone from ImageMagick-perl-6.2.8.0-15.el5_8 to ImageMagick-perl-6.5.4.7-6.el6_2.x86_64
#!/usr/bin/perl use warnings; use Getopt::Long; use Image::Magick; use IO::Handle qw( ); $| = 1; STDOUT->autoflush(1); # Mandatory options: # -f photo jpeg file (full path) GetOptions ( 'f=s' => \$photofile) or die ("can't do getops\n"); #Open the image as an Perlmagick object $ffoto = new Image::Magick; $x = $ffoto->Read($photofile); warn "can't open photofile:$x" if "$x"; $ffoto->Resize(geometry=>'x296'); $ffoto->Set(depth=>8); $ffoto->Rotate(degrees=>270); $ffoto->Negate(); $ffoto->Evaluate(value=>8, operator=>'Divide'); #Copy image to new image objects $yellow = $ffoto->Clone(); #Separate the colours - need to set depth again $yellow->Separate(channel=>'yellow'); $yellow->Set(depth=>8); ## ## EPCL output section ## #yellow: binmode STDOUT; $yellow->Write('gray:-'); print ("\r"); print ("\x1bIS 0\r"); #DEBUG print ("should be last line\n"); exit 0;
In reply to STDOUT buffering problem by illtud
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |