#! /usr/bin/perl open IN, "<", "abc.gif" or die "Unable to open input file: $!\n"; binmode IN ; local $/ ; $image = ; close IN ; open OUT, ">", "test.jpg" ; or die "Unable to open output file: $!\n"; binmode OUT ; print OUT $image ; close OUT ;