in reply to NET::FTP replaces characters in file with NULL

I have been unable to replicate your problem -- your code works fine for me (with all the CGI stuff cleaned out, anyhow). Are you sure the original file isn't empty? Is that file uploaded to the CGI, which then sends it on? If so, perhaps there's a bug elsewhere in your program. Note that I'm assuming it's a cgi because of the calls to param(). I can see that you're also new to perl, and probably came from C. Allow me to suggest that string handling doesn't need to be as complex as you make it out to be. Compare
my $localfile = sprintf("%s/%s", $params->get("Path.From"), $params->get("File"));

to
my $localfile = params->get("Path.From") . '/' . $params->get("File");

You also are using more than one variable with the same name, which can be confusing. I suggest you examine your usage of @hosts and $hosts in your program. Without the cleanup I did to make it not require CGI, I doubt your program would do what you'd expect it to. Below are some more comments..
I hope this helps.

Replies are listed 'Best First'.
Re: Re: NET::FTP replaces characters in file with NULL
by demerphq (Chancellor) on Apr 22, 2003 at 17:59 UTC
    You also are using more than one variable with the same name, which can be confusing. I suggest you examine your usage of @hosts and $hosts in your program.

    Personally I have no problem with using %hosts, @hosts and $hosts all in the same code. But thats just me. Now if @hosts contained something other than hosts, I would find that confusing. ;-) (Although I personally would lean towards %host @host and $host)


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
Re: Re: NET::FTP replaces characters in file with NULL
by mnlight (Scribe) on Apr 22, 2003 at 18:21 UTC
    no I am not using CGI. Some of our programs use it and some don't and in order to maintain some consistency we use the same configuration files we load the same files. I am sure that the file starts with data. Because one of the sub routines copies that file to make sure we don't loose it and the copied file has data. I also made sure that the cp() wasn't problem.