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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: How to retrieve files from ftp server
by Corion (Patriarch) on Nov 20, 2015 at 11:40 UTC

    This is not a code writing service. We help you learn and use Perl.

    Please show us what code you have already written and where it fails to address your problem and how solving it is problematic for you.

    As a start, see Net::FTP, and maybe some regular expressions like /^[A-Z][A-Z](\d\d)[A-Z][A-Z].txt$/.

      sorry for not being so specific and I really want to learn perl, but am a novice. Here is the code snippet I've written. I've declared wk as 02,but this changes every week and am not sure how to get that info. Also there may be other weeks files lying around in ftp server.

      sub getfilelist { my $ftp = shift; my @fileist = $ftp->dir or die "Unable to retrieve file listing"; my $WK = '02'; for my $file ( @filelist ) { next unless $file =~ m/ ^AB$WKCD.txt$/ or $file =~ m/ ^BC$WKDE +.txt$/; } }

        So your question is about how to determine the (current) week number? See localtime and Time::Piece::strftime for converting time to a number and back.

        It looks from this code fragment that you have not used strict. If you had, then your script would fail to compile because of the undeclared variables used in each regex. Those leading spaces don't look good either.

        Addendum: and you have mis-spelled "filelist" in its declaration.