Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: question regarding File::Copy, and hashes that contain file paths

by Leetsauce (Novice)
on Dec 12, 2015 at 16:29 UTC ( [id://1150120]=note: print w/replies, xml ) Need Help??


in reply to Re: question regarding File::Copy, and hashes that contain file paths
in thread question regarding File::Copy, and hashes that contain file paths

Error rename on 'e:/pervasive/staging/summit/C01' -> 'e:/pervasive/tes +t/APEX012015/C01': No such file or directory at pm/1150117.pl line 13 +.
This is now what I am running into. Any thoughts with dealing with this? It looks like it's searching for both the key -> value for the file path, or maybe I am misunderstanding the error.

Replies are listed 'Best First'.
Re^3: question regarding File::Copy, and hashes that contain file paths
by Your Mother (Archbishop) on Dec 12, 2015 at 18:15 UTC

    It is trying to do just what it says; move file1 (hash key) to file2 (value for that key). The -> is not code, just part of the message. So we’ll add a check for the original and a mkpath for the destination (if necessary) before doing the move; but it seems like you probably don’t have it unzipped the way you think–

    for my $key ( keys %files ) { my $original = path($key); die "There is no file $original" unless -f $original; my $destination = path($files{$key}); $destination->parent->mkpath unless -d $destination->parent; $original->move($destination); }
      Nah, it's unzipping appropriately(perfectly after applying some help I received here. thanks all!). The -> is referencing $zip, which as indicated by the code is the "get" for the archive. File::Copy will create the directory if necessary, so no need to mkdir. I *do* use dirmove, though, when taking it from the staging area to the production environment, after it has been renamed to the appropriate "APEX" prefix/suffix key/value combo. Basically, I'm unzipping payroll data for multiple companies, and trying to iterate through as much as I can without having to turn it into a c#, object-oriented executable because I am digging PERL so far, and want to continue to learn. Obviously, the code is newbish to the seasoned monk, but I'm learning at my own pace - in a business environment - while getting paid. Win/Win/Win =p Thanks for all your help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1150120]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-03-19 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found