Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Help with rename function
May 15, 2009, 7:56 pm
rate this thread
I have a perl script that ftp's to a server and downloads a file
everyday. The file name is currently called ag051509.txt(051509 is
the date and changes daily). I need to rename that file to agents.txt
using a script. Since the name changes everyday I need to do
something that is equivalent to ag*.txt in unix. Is there something I
can write that is close to -
Any help would be greatly appreciated. Thanks in advance!
Re: Help with rename function
How do you know what filename to ask for when you do the FTP request?
Save that name in a variable and then use that variable later
to rename the file.
Why "using a script"?
Why not "using the ftp program itself"?
ftp -o agents.txt firstname.lastname@example.org/path/to/ag051509.txt
You think you need to, but you do not need to.
The technical name for those ag*.txt thingies in unix is a "glob",
or more accurately, a "filename glob".
No, because rename() takes only 2 arguments, and ag*.txt may expand
to more than 1 filename.
Also no because strings need quotes around them.
perldoc -f glob
You could use a List Slice to ensure that the glob returns only
rename( (glob 'ag*.txt'), 'agents.txt');
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"