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

move the file to other folder

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

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 11: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 13: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 Fastolfe (Vicar) on Aug 07, 2000 at 17: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.
Re: move the file to other folder
by vrempire (Sexton) on Aug 07, 2000 at 16: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.

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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-25 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found