phemal has asked for the wisdom of the Perl Monks concerning the following question:

i want to walk through the source code of Net::Ftp module in perl. Can u please tell me where exactly (i.e directory structure), i can look for in on my linux box. I want to specify the timeout for ftp connection as i am not able to use NET::FTP with Expect Language. Is there any way wherein i can specify it manually. ex- ftp 172.16.232.185 --timeout
  • Comment on i want to go through the code of Net::Ftp module in perl

Replies are listed 'Best First'.
Re: i want to go through the code of Net::Ftp module in perl
by chargrill (Parson) on Oct 11, 2006 at 06:04 UTC

    If you want to see where it's located, you can do:

    perldoc -l Net::FTP

    And if you prefer paging around the module in, say, vi or vim, you can do something like:

    vi `perldoc -l Net::FTP`


    --chargrill
    s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

      Interesting. The immediate bash evolution to that is:

      function pmvi { vi $(perldoc -l "$@"); }

      It even works with more than one module at a time (because perldoc -l does, of course).

      --
      David Serrano

Re: i want to go through the code of Net::Ftp module in perl
by syphilis (Archbishop) on Oct 11, 2006 at 06:08 UTC
    Hi,
    Perl will tell you the location of Net/FTP.pm. Just enter the following at the prompt:
    perl -MNet::FTP -e 'print $INC{"Net/FTP.pm"}, "\n"'

    Cheers,
    Rob
Re: i want to go through the code of Net::Ftp module in perl
by Khen1950fx (Canon) on Oct 11, 2006 at 06:00 UTC
    The easiest way: perldoc -m Net::FTP
Re: i want to go through the code of Net::Ftp module in perl
by quester (Vicar) on Oct 11, 2006 at 06:04 UTC
    If you want to find it in the directory structure, look for a file named "FTP.pm". On my Cygwin box:
    $ locate Net/FTP.pm /lib/perl5/5.8/Net/FTP.pm /usr/lib/perl5/5.8/Net/FTP.pm
      Note that /usr/lib is usually mounted to the same dir as /lib under cygwin, so there aren't actually two copies.

      In the general case, this is a bad idea. After a box has been running for a while and modules are upgraded, Perl is upgraded, you'll wind up with many copies of the file. Do this, and you risk the chance of looking at one file, but Perl looks at another.

      Checking on one of my older hosts, running locate Net/FTP.pm returns 13 files. Ask perl to tell you which module is used, as per the other replies in this thread.

      • another intruder with the mooring in the heart of the Perl

Re: i want to go through the code of Net::Ftp module in perl
by lyklev (Pilgrim) on Oct 11, 2006 at 19:40 UTC
    Net::FTP has a default timeout of 120 seconds, but you can override the timeout in the constructor:
    my $ftp = Net::FTP->new("some.host.name", Timeout => 50) or die "Cannot connect to some.host.name: $@";

    I pretty much copied this literally from the perl documentation, which you can access on a system with perl correctly installed with

    perldoc Net::FTP
    I only replaced the 'Debug' option, which, now that I think about it, might be a pretty good idea too. Options can be specified in the constructor as
    my $ftp = Net::FTP -> ("some.host.com", Debug => 1, Timeout => 50, Option => value, Option => value ...);
Re: i want to go through the code of Net::Ftp module in perl
by maspalio (Scribe) on Oct 11, 2006 at 09:37 UTC
    Or the brute force way:

      % find /usr/lib -path '*/Net/FTP.pm' -print

    HTH.
Re: i want to go through the code of Net::Ftp module in perl
by nimdokk (Vicar) on Oct 11, 2006 at 16:04 UTC
    Actually, I believe the timeout period can be set when you construct a new FTP object. Take a look at the docs for Net::FTP and look at options under the "new" construction.