Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Leetsauce (Novice)
on Dec 17, 2015 at 21:13 UTC ( [id://1150647]=note: print w/replies, xml ) Need Help??


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

How would I check to see if the file exists with this? So we have @f defined as the list of company numbers (C## - which represents company ID ) and for each of those, we're renaming the directory and moving it, but it breaks when it hits the key that does not exist in the folder (company 6 is not inside my zip, but it is a possible company that CAN be in the zip) so I'm looking for a quick way to check if the actual file, that corresponds with the key in our @f, even exists because if it doesn't, i need to skip it. I think this will involve next, or exists, or maybe both. Any insight?
  • Comment on Re^4: question regarding File::Copy, and hashes that contain file paths

Replies are listed 'Best First'.
Re^5: question regarding File::Copy, and hashes that contain file paths
by poj (Abbot) on Dec 17, 2015 at 21:32 UTC

    see file exists test -e -X

    foreach my $key (sort keys %compHash) { my $from = $src.$key; next unless (-e $from); . .
    poj
      This is exactly what I needed. I ended up using:
      my $base_path = 'e:/iwantfileshere'; dirmove($from,$to) if -e $base_path;
      Thank you for your help!

        I think you should use closer to the version I showed :P with -f and -d and maybe mix in -r but the functions should report that kind of problem if it arises. -e might mean a directory exists but it also could be a file or a link and probably more.

Log In?
Username:
Password:

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

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

    No recent polls found