in reply to Re: How to retrieve files from ftp server
in thread How to retrieve files from ftp server

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$/; } }

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

    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.

      Ok, thank you very much for looking into this. Let me dig through these functions in detail and get back to you if need further help in this regard. Much appreciated!

Re^3: How to retrieve files from ftp server
by hippo (Archbishop) on Nov 20, 2015 at 12:22 UTC

    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.