If the image is rather small, you could also try something like:
or shorter:my $imageContent = do { open (my $IN, "<", $image) or die "Error in reading '$image': $!"; binmode($IN); local $/ = undef; my $content = <$IN>; close($IN); return $content; }; # do open (my $OUT, ">", $outfile) or die "Error: couldn't write '$outfile': $!\n"; } # unless binmode($OUT); # thanks to pKai print $OUT $imageContent; close($OUT) or die "Error: couldn't close '$outfile': $!";
my $imageContent = do { open (my $IN, "<", $image) or die "Error in reading '$image': $!"; binmode($IN); local $/; # defaults to undef <$IN>; # close happens automatically at end of block if # you use a lexical variable as filehandle }; # do open (my $OUT, ">", $outfile) or die "Error: couldn't write '$outfile': $!\n"; binmode($OUT); # thanks to pKai print $OUT $imageContent; close($OUT) or die "Error: couldn't close '$outfile': $!";
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
In reply to Re^3: create image via binmode
by strat
in thread create image via binmode
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |