DESCRIPTION

The module is a non-blocking wrapper around Net::FTP module with an accent on "wrapper". In other words, to use this module you'd need to read up the docs for Net::FTP module as this wrapper is literally a wrapper.

The is also a module POE::Component::Client::FTP, you might want to check it out although it was not fitting my requirements hence the creation of this module.

The spawn method returns a POE::Component::Net::FTP object. It takes a few arguments, all of which are optional. The possible arguments are as follows:

alias

->spawn( alias => 'ftp' );

Optional. Specifies a POE Kernel alias for the component.

stop_on_error

->spawn( stop_on_error => 1 );

Optional. Takes either true or false values. If set to a true value will stop and return if any of the series of commands failed. Otherwise will try to execute all the commands (this probably won't make sense until you read up on process() method/event). Defaults to:1

options

->spawn(
options => {
trace => 1,
default => 1,
},
);

Optional. A hashref of POE Session options to pass to the component's session.

debug

->spawn(
debug => 1
);

When set to a true value turns on output of debug messages. Defaults to:0.

commands

Mandatory. This is the "wrapper" part. The commands argument takes an arrayref of hashrefs. The first call to this event/method must contain new as the first command afterwards the Net::FTP object will be the same one until you pass in a new new command. The hashrefs are all single key/value pairs. The key is the method of Net::FTP object you wish to call and the value is an arrayref of arguments to pass into that method. Error checking will be done by the component, see "OUTPUT" section for details.

OUTPUT

The event handler set up to handle the event which you've specified in the event argument to process() method/event will recieve input in the $_[ARG0] in a form of a hashref. The possible keys/value of that hashref are as follows:

responses

'responses' => [ [ 1 ],
[ '1' ],
[ 'test.txt' ]
]

The responses key will contain an arrayref as a value. Each element of that arrayref will also be an arrayref which will be the return value of the "command" which was passed into commands arrayref to process() event/method (i.e. the return value of the "command" passed as a third element in commands arrayref will be the the third element in responses arrayref). If a particular command (read "method call") failed the return value will be the return value of Net::FTP's message() method (where applicable), for new() method (on falure) the element will contain the value of $@.

is_error

{ 'is_error' => 'login' }

If any of the methods listed in commands arrayref of process event/method failed then is_error key will be present and it's value will be the name of the method that failed.

last_error

{ 'last_error' => 'Login authentication failed' }

If any of the methods listed in commands arrayref of process event/method failed then last_error key will be present and it's value will be the error message explaining the falure.

user defined

{ '_blah' => 'foos' }

Any arguments beginning with _ (underscore) passed into the EXAMPLE() event/method will be present intact in the result.