sub sendFile { # application object my $self = shift; # load template files my $tmpl = $self->param('info' => $self->load_tmpl ('info.phtml')); # create an ftp object my $ftp = Net::FTP->new("XXX.XX.XX.XXX", Debug => 1, Port => 21) or die "Cannot connect to host: $@"; # login to the ftp server $ftp->login("user",'pass') or die $ftp->message; # get root directory $ftp->cwd() or die $ftp->message; # get the filename my $filename = "dir+filename"; # check if file exist if(-e $filename){ # send file in binary mode $ftp->binary; # send a file to the remote server $ftp->put($filename) or die $ftp->message; } # quit the ftp connection $ftp->quit; # output return $tmpl->output; } sub deleteFile { # application object my $self = shift; # load template files my $tmpl = $self->param('info' => $self->load_tmpl ('info.phtml')); # create an ftp object my $ftp = Net::FTP->new("XXX.XX.XX.XXX", Debug => 1, Port => 21) or die "Cannot connect to host: $@"; # login to the ftp server $ftp->login("user",'pass') or die $ftp->message; # get root directory $ftp->cwd() or die $ftp->message; # get the filename my $filename = "filename"; # delete a file to the remote server $ftp->delete($filename); # quit the ftp connection $ftp->quit; # output return $tmpl->output; }