File::Copy help needed 
Author Message
 File::Copy help needed

What is wrong with the following code?  The expected .html page is generated
and returned when the copy statement is commented out, but if the copy
statement is executed it seems to go off somewhere, and I am returned a
generic blank .html page generated by I don't know what.  I am running under
Unix and an Apache server (www.hiway.net).

Steve Guidos

----------------------------

#! /usr/local/bin/perl
print "Content-type: text/html\n\n";

use File::Copy;
$FileToCopy = "/images/bk1.jpg";
$NewFile = "/images/background.jpg";
Copy($FileToCopy, $NewFile);

print <<"the_end";
<html><head><title>File Copy Test Page</title></head><body>
The file name to copy is $FileToCopy<br>
The new file name is $NewFile<br>
</body></html>
the_end



Sun, 26 Aug 2001 03:00:00 GMT  
 File::Copy help needed

Quote:

>#! /usr/local/bin/perl

Adding a '-w' might help.

Quote:
>print "Content-type: text/html\n\n";

>use File::Copy;
>$FileToCopy = "/images/bk1.jpg";
>$NewFile = "/images/background.jpg";
>Copy($FileToCopy, $NewFile);

Shouldn't that be 'copy' (rather than 'Copy')?
Maybe you should check for success as well.

Good luck.

--

Alastair




Mon, 27 Aug 2001 03:00:00 GMT  
 File::Copy help needed

Quote:

>>use File::Copy;
>>Copy($FileToCopy, $NewFile);

>Shouldn't that be 'copy' (rather than 'Copy')?

Yes, that was a problem.  Now for the silly question:  since Perl is
(supposed to be) case sensitive in its naming conventions, why is the module
declared in partial uppercase (F)ile::(C)opy while the statement itself must
be lowercase (c)opy?

Steve Guidos



Mon, 27 Aug 2001 03:00:00 GMT  
 File::Copy help needed

Quote:

> Yes, that was a problem.  Now for the silly question:  since Perl is
> (supposed to be) case sensitive in its naming conventions, why is the module
> declared in partial uppercase (F)ile::(C)opy while the statement itself must
> be lowercase (c)opy?

That's just a common convention in Perl: module names are Mixed::Case,
function and method names are lower_case.  There's no hard-and-fast
requirement for this, but it will make your code more normal -- just as
using camelCase for your Java methods will make them look more "normal"
(for the Java definition of normal), and UPPERCASE for macros in C,
globals in Perl, and constants in Java will look more normal.

Luckily, Perl is blessed with a document that explains its conventions:
"perldoc perlstyle".

A nit: "copy" in this context is not a statement, it's a function.  In
Perl, statements are little chunks of code separated by semicolons, not
language keywords.  The confusion of "keyword" with "statement" is
largely an artifact of ill-conceived legacy languages like BASIC and
fortran.

        Greg
--

Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, {*filter*}ia, USA  20191-5434               fax: +1-703-620-0913



Mon, 27 Aug 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Help needed to copy files

2. Help needed to copy files

3. Help needed to copy files

4. Using File::Copy and Sockets to copy public files from http addresses

5. File::Copy, copying files problem.

6. Need help on some copy program

7. Warning using copy from File::Copy

8. Semantics of File::Copy::copy(,)

9. Seek Help for copying binary files

10. Help with opening and copying to a file

11. Newbie help: copying files

12. Copying an exec file!!HELP!!

 

 
Powered by phpBB® Forum Software