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:ath;
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.
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:ath;
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.