in reply to Re^2: create image via binmode
in thread create image via binmode
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"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: create image via binmode
by pKai (Priest) on Jan 15, 2006 at 12:48 UTC | |
|
Re^4: create image via binmode
by ikegami (Patriarch) on Jan 14, 2006 at 18:56 UTC | |
by strat (Canon) on Jan 15, 2006 at 10:21 UTC | |
by ikegami (Patriarch) on Jan 15, 2006 at 17:59 UTC |