Copy with relative paths? / Glob w/UNC?

A

Antgoodlife

Hi All...

I'd like to have the target of this copy be a folder underneath
where the perl script is executed from without using the full D:\
Absolute path.... : (That way the script is a little more portable)..
(this is running on Windows PERL 5.10.)

D:\Script>mkdir CopyOfData
D:\Script>type myrename_and_copy.pl
#perl -w
use strict;
use File::path;
use File::Copy;

chdir "\\\\myserver\\myshare";
for my $file (<*>) {
$file =~ m/^(.*)_.*$/;
copy($file, "d:\\Script\\CopyOfData\\$1") or die "File cannot be
copied.";
}
#-------------- Done
d:\Script>perl myrename_and_copy.pl



This works fine as above.. but to me it's a poor "workaround" because
from what I can tell I can't put the UNC path in either the copy
source or the glob angle brackets.. I need to use CHDIR first. (And
because I changed directories now I need to use the absolute path to
the target instead of just my "CopyOfData" folder.

I'm pretty sure I can get it to work if I use CWD and save the
current directory before I change to the server source share (Just as
ugly I believe) However, I want to ask the group before I go this
route if there's a better way.

Thanks in advance. Let me know if I didn't include enough info also,
Thanks a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top