Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading and image and then saving it to a new location 1

Status
Not open for further replies.

SCelia

Programmer
Feb 27, 2002
82
CA
Heres the problem:

open (IMAGE, "image.jpg") or die "Cannot open file image.jpg: $!";

binmode IMAGE;
read( IMAGE, $doc, 10000 );
close IMAGE;

it seems to read in okay. Now I try to create that image in a new directory:

open(IMAGE, ">D:\Earth\unique\newimage.jpg") || die"newimage.jpg: $!";

binmode IMAGE;
print IMAGE $doc;
close IMAGE;

The code doesn't die, but it doesn't create any images either. Any ideas?
Celia
 
Try

open(IMAGE, ">D:\\Earth\\unique\\newimage.jpg") || die"newimage.jpg: $!";

instead.
Perfection in engineering does not happen when there is nothing more to add. Rather it happens when there is nothing more to take away.
 
sub copy_tmpfile {
my ($source,$destination) = @_;
open (FILE2,">$destination");
binmode(FILE2);
while (!eof($source)) {
$ligne=<$source>;
print FILE2 ($ligne);
}
close (FILE2);
}
# could this do ?

---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Thanks, that did it. New problem now tho, refer to my latest post. Celia
 
Never mind, my bad logic. Used an unless where an if was called for:( I must be tired. Celia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top