homepage Welcome to WebmasterWorld Guest from 54.198.42.105
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
How rename file in different folder ...
How rename file in different folder ...
StopSpam




msg:442626
 2:22 pm on Jul 25, 2003 (gmt 0)

Dear perl guruís i have a simple renaming and path question:
the below codes renames news.dat to newsold.dat

###############
$old = "news.dat";
$new = ".newsold.dat";
rename($old, $new) or system("mv", $old, $new);
###############

But above code only works if the file news.dat is in the same directory
as the script with the above code

My Question is:

How can the above code rename a file that is in a different dir then cgi-bin script itself ..
how do i tell script the file is in different folder ...

The reason i ask this is because i am afraid if i include the path to $old like:
$old = "/home/public_html/news.dat";
i am afraid it will rename the complete dir to $new?

The path to $old is: $old = "/home/public_html/news.dat";

i have no idea how to tell the script that the file is in diff dir ...
Please advise .. thanks

 

marcs




msg:442627
 7:57 pm on Jul 26, 2003 (gmt 0)

Simply use :

$old = "/home/public_html/news.dat";
$new = "/home/public_html/.newsold.dat";
rename($old, $new)

It will not rename the directory, only the file, as you want.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved