# writing binary files, not a good example #show error cause "die $!" open (SOURCEFILE, "mysubdir/image1.jpg") || die "$!";; open (DESTFILE, ">mysubdir/copied.jpg") || die "$!"; binmode (SOURCEFILE); #change to binary mode binmode(DESTFILE); @contents = ; print DESTFILE @contents; close SOURCEFILE; close DESTFILE; #check file properties if (-e "mysubdir/copied.jpg") { print "file exists"; }