I’m writing a test for an FTP server in Perl, but I cannot get the messaging I want. Currently I wrote a mini program that looks like this;
my $ftp = Net::FTP->new($host, Debug => 0) or die "Cannot connect to $host: $@";
print @{[ $ftp->message ]}, "\n";
Which works wonderfully, but my response is;
FTP SERVER
Instead of the actual response;
220 FTP SERVER
I cannot find any information other than the basic methods and options. Does anyone know where to find the full documentation?
First complete documentation for Net::FTP is available at the Perl Programming Documentation website. It’s a very nice little page showing all the standard Perl modules, Perl tutorials, Perl language guides, the FAQ, and other built-in Perl documentation. That’s right, all of the information on this website is already on your computer.1
All you need is the
perldoccommand. For example, what does the Perl function shift do?Almost all modules have the same built-in documentation. Since
Net::FTPis part of the standard Module set, you can simply sayperldoc Net::FTPand get the complete documentation.This is part of the Perl POD (Plain old doc) documentation system. If you’re serious about Perl programming, I suggest you learn about Perl POD and use it in your scripts. In fact, there’s a nice standard module called Pod::Usage that can be used to display program help text directly from your POD documentation.
Okay, but what if the complete documentation for that module …uh what’s the technical term? Oh yeah… sucks? What if the documentation simply doesn’t contain the information you’re looking for?
In that case, you’re going to have to roll up your sleeves and dive deep into the code. Again,
perldoccan help you there too:Now, you know where the module is stored on your system. You can now use your favorite editor to go through the code.
Just one more tiny thing: In
Net::FTP‘s code, there’s this statement:That means that
Net::FTPis a sub-class ofNet::CmdandIO::Socket::INET. You might have to do aperldocon these modules to find out more information. It could very well be that the error message you’re getting is being generated by one of these two classes, and not byNet::FTP.I can see in the code that the message you’re getting is from
Net::Cmd->message. You might have to dig through that to see why you’re not getting the message you think you should. From what I can see, it looks like it’s simply returning the message from the FTP server itself. It could be that the FTP server you’re connecting to is based upon older code that doesn’t return the response code.1 Note that the default documentation for the Perl Programming Documentation website is for Perl 5.14 which may or may not be your Perl version. You can adjust the Perl version via the drop down menu on the left of the webpage. Still, for a wide variety of reasons this website might not reflect your version of Perl installed on your system.