Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
XP is just a number
 
PerlMonks  

move the file to other folder

by vrempire (Sexton)
on Aug 07, 2000 at 07:20 UTC ( [id://26514]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

vrempire has asked for the wisdom of the Perl Monks concerning the following question:

hi guys,I have a question.How I gonna move the file from one folder to the other folder,such as the child folder? so that,when the perl script is run,the file is move to the child folder and the file is delete on the current folder?

Replies are listed 'Best First'.
Re: move the file to other folder
by ar0n (Priest) on Aug 07, 2000 at 07:53 UTC
    #!/usr/bin/perl -w use strict; use File::Copy; my $source = "/original/dir/some_file"; my $dest = "/other/directory/"; move($source, $dest) or die "Error moving file: $!\n";


    -- ar0n | Just Another Perl Joe

Re: move the file to other folder
by agoth (Chaplain) on Aug 07, 2000 at 09:34 UTC
    Hi,
    This is what, your fifth post about file manipulation? and so far all the responses have been pretty helpful, but its going to be a long slow process learning perl if you ask questions every for every single problem.

    perlfaq5 contains some if not all of the answers and the ActiveState docs contain help for the CGI/server side issues you are coming across with permissions.
    From the command line: perldoc perlfaq5
    Perl . Com for more links.

    We can and probably will help, but docs are your friend.

Re: move the file to other folder
by vrempire (Sexton) on Aug 07, 2000 at 12:24 UTC
    agoth, thanks for your advice.I'm really a beginner in perl,and also in perlmonks.I will try my best to do perl programming. thanks again.
RE: move the file to other folder
by Fastolfe (Vicar) on Aug 07, 2000 at 13:31 UTC
    You can usually just use rename(), though this is somewhat implementation-dependent. If you're under Unix and not moving the file across filesystems, this is simplest, as it just changes the directory entries. I believe File::Copy's move() function attempts this first, and if it fails, tries to copy the file and unlink the source, so that's probably your best bet.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://26514]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.