Dru has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I'm pulling my hair out on this one. I have the following script:
3 use strict; 4 use warnings; 5 use Net::FTP; 6 use Win32::Fileop; 7 8 Map F => '\\\\192.168.13.15\\c$', { persistent => 1 } 9 10 my $hostname = '192.168.14.3'; 11 my ($user, $pass) = ("user",'password'); 12 my $Local = 'f:\winnt\win32\system32\dhcp\'; 13 my $day = qw(Sun Mon Tue Wed Thu Fri Sat)[(localtime())[6]]; 14 my $file = "dhcpsvrlog\.$day"; 15 16 my $ftp=Net::FTP -> new($hostname) or die ("Connect failed"); 17 $ftp->login($user,$pass) or die ("cant Login"); 18 $ftp->put($file) or die ("Can't upload"); 19 $ftp->quit; 20 21 unmap F
and I keep getting the error:
syntax error at cp_dhcp_logs.pl line 8, near "Map F" Execution of cp_dhcp_logs.pl aborted due to compilation errors.
When I run it.

I followed the Win32::Fileop documntation to a tee, but it's still not working. Also, when I run it as such:
use strict; use warnings; use Win32::FileOp; Map F => '\\\\192.168.13.15\\c$', { persistent => 1 }
I don't get an error. Does anyone know what could be wrong?

Thanks,
Dru

Replies are listed 'Best First'.
Re: Problem With Win32::Fileop
by Mr. Muskrat (Canon) on Jan 14, 2003 at 17:36 UTC
    Line 6, change Fileop to FileOp. Module names are case-sensitive.

    Line 8, add a semicolon to the end of the line.

    Line 10, either double your backslashes or change them to forward slashes otherwise you end up with a runaway string.

    Line 21, you may need to write it as Unmap F;

Re: Problem With Win32::Fileop
by John M. Dlugosz (Monsignor) on Jan 14, 2003 at 20:07 UTC
    On Windows, the file name of the pm file is case-insensitive, but the module name within it is still case sensitive. So perl.exe finds Win32\FileOp.pm and loads it, but then tries to call Win32::Fileop->import, which does not exist.

    I recall getting an error on the use line when the module name doesn't match the file name. Maybe it varies with different versions of perl, or something else is going on (like Fileop without the cap 'O' is also used internally so the namespace exists).

    Anyway, Map is never imported.

    —John