in reply to Moving Files

I assume the program has directory $wDir as its current working directory, and $transFile starts with the directory part "docTmp/coded/".

If the target directory .../tmp is not present, the file to be moved will be placed in the parent directory instead and will be renamed to tmp. So I would make sure beforehand that the target directory exists.

For the creation of directories of any depth, use mkpath() from core module File::Path. For moving you could use Perl's File::Copy module. It has a portable move() function. I would do it like this (untested):

# read trans barcode $primer = Util::Util::trim(Util::Util::fileDecode($transFile)); # set transaction folder path my $transPath = "plsTrans/" . $primer . "/tmp/"; use File::Path qw(mkpath); # create the target directory if there is none if (!-d $transPath) { mkpath $transPath or die "cannot create target directory $transPat +h:$!\n"; } use File::Copy qw(move); move($transFile, $transPath . $transFile) or die "move to $transPath failed: $!";

Replies are listed 'Best First'.
Re^2: Moving Files
by rottmanja (Initiate) on Aug 07, 2008 at 18:29 UTC
    I can verify that the ../tmp folder will always be available. Right now things are very static. I have manually created all the directories and given proper permissions(777) just for testing and ease of development.

    When using move(..), I wind up getting the error move to /mnt/fds-phx/plsTrans/9DFA109A-B562-1BEA-064686FE31CA2F93/tmp/ failed: Is a directory at Lib/PLSParse.pm line 130.

    The output I get from the paths I have created is below.

    $transFile = /mnt/fds-phx/docTmp/coded/1.tif $transPath = /mnt/fds-phx/plsTrans/9DFA109A-B562-1BEA-064686FE31CA2F93 +/tmp/