Copy with relative paths? / Glob w/UNC?

Discussion in 'Perl Misc' started by Antgoodlife, Feb 12, 2009.

  1. Antgoodlife

    Antgoodlife Guest

    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.
     
    Antgoodlife, Feb 12, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tor Rest

    Copy using UNC paths

    Tor Rest, Aug 11, 2003, in forum: Perl
    Replies:
    1
    Views:
    3,768
    J├╝rgen Exner
    Aug 12, 2003
  2. Georgy Pruss
    Replies:
    15
    Views:
    757
    Tim Roberts
    Dec 1, 2003
  3. Tim Peters
    Replies:
    1
    Views:
    383
    Duncan Booth
    Dec 1, 2003
  4. Sean Berry

    Question about glob.glob <--newbie

    Sean Berry, May 4, 2004, in forum: Python
    Replies:
    3
    Views:
    359
    David M. Cooke
    May 4, 2004
  5. Elbert Lev

    glob.glob unicode bug or feature

    Elbert Lev, Jul 31, 2004, in forum: Python
    Replies:
    5
    Views:
    419
    Neil Hodgson
    Aug 2, 2004
Loading...

Share This Page