Please forgive me, as i don't get much time for enjoying the features of perl but I'm having trouble understanding why a copy statement isn't actually copying anything? the basic precept of what you are seeing is the following, create a new directory (yes unfortunately on Windows), read a directory and copy everything to the new directory. I'm probably missing something basic, but my feable mind isn't following this one.
here is the code...
use strict; use File::Copy; use diagnostics -verbose; my $trailer = qw( \ ); my $dev_dir = 'V:\dblomber\authdev' . $trailer; my $qa_dir = 'V:\dblomber\authqa' . $trailer; my $qa_pre_new_dir = 'V:\dblomber\auth'; my $all_qa_files; #get date yyyymmdd to append to new dir my($sec,$min,$hour,$mday,$mon,$year) = localtime; my $current_date = sprintf("%04d%02d%02d", $year+1900,$mon+1,$mday); my $qa_new_dir = $qa_pre_new_dir . $current_date . $trailer; mkdir $qa_new_dir; print "CREATED NEW ARCHIVE DIR:$qa_new_dir:\n"; opendir (QA, $qa_dir) or die "Cannot open $qa_dir $!"; print "OPENED $qa_dir\n"; opendir (QAN, $qa_new_dir) or die "Cannot open $qa_new_dir $!"; print "OPENED $qa_new_dir\n"; foreach $all_qa_files (sort readdir(QA)) { enable diagnostics; copy ("$qa_dir$all_qa_files", "$qa_new_dir$all_qa_files") or d +ie "copy Failed: $!"; print "COPYING FILE:$qa_dir$all_qa_files\t to $qa_new_dir$all_ +qa_files\n"; disable diagnostics; }
here is the output.
CREATED NEW ARCHIVE DIR:V:\dblomber\auth20060221\: OPENED V:\dblomber\authqa\ OPENED V:\dblomber\auth20060221\ Uncaught exception from user code: copy Failed: at T:\My Documents\perl\release.pl line 37. at T:\My Documents\perl\release.pl line 37
Here is the question.
why doesn't this work?
if I comment out the "copy" statement the print statement appears correct but the copy is failing?
output of just print statement.
CREATED NEW ARCHIVE DIR:V:\dblomber\auth20060221\: OPENED V:\dblomber\authqa\ OPENED V:\dblomber\auth20060221\ COPYING FILE:V:\dblomber\authqa\. to V:\dblomber\auth20060221\. COPYING FILE:V:\dblomber\authqa\.. to V:\dblomber\auth20060221\. +. COPYING FILE:V:\dblomber\authqa\crap.txt to V:\dblomber\auth20 +060221\crap.txt COPYING FILE:V:\dblomber\authqa\sample.doc to V:\dblomber\auth20 +060221\sample.doc FINISHED COPYING FILES CLOSED V:\dblomber\authqa\

In reply to Yet Another File::Copy problem by djbiv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.