CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
rename file after script finishes

 



sg3
New User

Jan 28, 2013, 5:17 AM

Post #1 of 2 (484 views)
rename file after script finishes Can't Post

Hey guys,

I'm a little stuck here. I have a perl script that is working on couple of files and saving them to a directory and right now it's something like this:


Code
gzcat my_file1.gz | my_perl.pl > tmp_output_file1.txt


So the question is quite simple but I can't figure out how to do it in the perl file. I need to, when the script has finished working one 1 file, to rename just that 1 files. Please note that the same script is working on couple of files at a time, so in same directory there might be a file with name tmp_output_file2.txt for example that is not finished and it shouldn't be renamed.

Thanks


Laurent_R
Veteran / Moderator

Jan 29, 2013, 5:51 AM

Post #2 of 2 (478 views)
Re: [sg3] rename file after script finishes [In reply to] Can't Post

Just try this:


Code
rename $old_name, $new_name;


If you wrote to the file, make sure your file is closed before doing this.


(This post was edited by Laurent_R on Jan 29, 2013, 5:52 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives