Sample code for 30+ languages & platforms
Perl

Delete Remote File

See more FTP Examples

Delete a remote file.

Chilkat Perl Downloads

Perl
use strict;
use warnings;
use Chilkat2;

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

my $ftp = Chilkat2::Ftp2->new;

$ftp->Hostname('ftp.chilkatsoft.com');
$ftp->Username('myLogin');
$ftp->Password('myPassword');

# Connect and login to the FTP server.
my $success = $ftp->Connect();
if (!$success) {
    print $ftp->LastErrorText, "\n";
    exit;
}

# Set the current remote directory to where the file
# is located:
$success = $ftp->ChangeRemoteDir('/testing');
if (!$success) {
    print $ftp->LastErrorText, "\n";
    exit;
}

$success = $ftp->DeleteRemoteFile('goodbye.txt');
if (!$success) {
    print $ftp->LastErrorText, "\n";
    exit;
}

$success = $ftp->Disconnect();