Patricia Hinman wrote: > Everything "was" perfect in my little program. I gave > it a test run today. My file which copies some > demofiles is sending blank empty files. I've used -e > to make sure it exists and checked the return value on > the copy(). Both check out fine. But the files have > no content. > > Any suggestions? > > This is a snippet from one copy statement: > > my$ok = ""; > $ok = > copy("/$htmlroot/$htmldir/demosite/$filenames[$i]","/$htmlroot/$htmldir/$files[$i]") > || push(@messages, "Couldn't copy > /$htmlroot/$htmldir/demosite/$filenames[$i],\n to > /$htmlroot/$htmldir/$files[$i]\n Error: $!");
One validation approach at a time. You are assigning the return value of the copy staement to $ok, OK? If you need to add the error message to the messages array, you can do that on a separate line, with nuch greater clarity: $ok = copy($demodir . '/' . $filenames[$i], $targetdir . '/' . $files[$i]) if (!$ok) { push(@messages, "Couldn't copy $demodir/$filenames[$i],\n" . "to $targetdir/$files[$i]\n Error: $!"); } The or operator should be a tool, not a mantra. > if(-e "/$htmlroot/$htmldir/$files[$i]" && $ok){ > push(@messages, "Copied > /$htmlroot/$htmldir/demosite/$filenames[$i],\n to > /$htmlroot/$htmldir/$files[$i]"); > } > > Anybody see a mistake??? Since $ok will have a value whether or not the file copy succeeded, and since at least the filename is copied, WHETHER OR NOT the original existed, you have no real test here. I don't know, Patricia. Following the principle of KISS, I just used File::Copy to copy a stray mpeg from my test directory for this list to its parent directory, as follows: #!/usr/bin/perl -w use strict; use warnings; use File::Copy; copy ("venus.mpg", "..\\venus.mpg"); Then I went to Explorer, clicked on the newly-copied venus.mpg in the target directory, and was treated to a thirty-second simulation of a Venus flyover, as seen through the clouds. File::Copy works fine. Uncomplicate your code a little, do one thing at a time, and see what you get. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]