I am using Net::FTP. I can connect, log in, and put a file. I need also to be able to delete files. But when I invoke the delete() method, it says it can't locate it.
$ cat testDelete.pl #!/usr/bin/perl use strict; use warnings; use Net::FTP; use shipments; use constant FALSE =>0; use constant TRUE =>1; my $DEBUG = TRUE; ###################################################################### +# # returns TRUE if successful sub ftpDeleteRemoteFile($$$$) { my ($host, $user, $password, $remoteFile) = @_; my $ftp = Net::FTP->new($host, Debug => $DEBUG); if (! $ftp) { print "Cannot make FTP connection to $host: $@\n"; return FALSE; } if (! $ftp->login($user, $password)) { print "Cannot log in via FTP connection as $user to $host: " +. $ftp->message . "\n"; $ftp->quit; return FALSE; } if (! ftp->delete($remoteFile) ) { print "Cannot delete file $remoteFile from host $host\n"; $ftp->quit; return FALSE; } $ftp->quit; return TRUE; } ftpDeleteRemoteFile(getShipperHost(), getShipperUser(), getShipperPass +word(), "to/csgload/testfile1"); # Keep the perl compiler happy TRUE; The output I get is: $ testDelete.pl Net::FTP>>> Net::FTP(2.77) Net::FTP>>> Exporter(5.58) Net::FTP>>> Net::Cmd(2.29) Net::FTP>>> IO::Socket::INET(1.29) Net::FTP>>> IO::Socket(1.29) Net::FTP>>> IO::Handle(1.25) Net::FTP=GLOB(0xfdd3e0)<<< 220 Welcome to XXX FTP service. Net::FTP=GLOB(0xfdd3e0)>>> USER YYY Net::FTP=GLOB(0xfdd3e0)<<< 331 Please specify the password. Net::FTP=GLOB(0xfdd3e0)>>> PASS .... Net::FTP=GLOB(0xfdd3e0)<<< 230 Login successful. Can't locate object method "delete" via package "ftp" (perhaps you for +got to load "ftp"?) at /home/stats/csgload/bin/perl/testDelete.pl lin +e 32.
(host and username changed, obviously)

I have perl 5.8.8, and version 2.77 of Net::FTP


In reply to In Net::FTP, "Can't locate object method "delete" via package ftp..." by tgeliot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.