Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How to retrieve files from ftp server

by Corion (Patriarch)
on Nov 20, 2015 at 11:40 UTC ( [id://1148223]=note: print w/replies, xml ) Need Help??


in reply to How to retrieve files from ftp server

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$/.

Replies are listed 'Best First'.
Re^2: How to retrieve files from ftp server
by Rajiram (Initiate) on Nov 20, 2015 at 11:57 UTC

    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.

        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!

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1148223]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found