Okay now I am really peeved off... I have been working on this freaking script for the past two days... I though i had it, but no there is something wron with. And I knoW.... I KNOW... I have no idea what it is.

What I've been trying to do is copy a directory structure to a new directory and copy the files along. Now I have done this before with no troubles, but for some odd reason in this script alone the mkpath doesn't work.

#Module use to recurse files in directory use File::Find; #Module used to copy files use File::Copy; #Module to copy directory structure use File::Path; if(defined($ARGV[0]) && defined($ARGV[1])) { $ARGV[0] =~ s/\\/\//g; $ARGV[1] =~ s/\\/\//g; print "$ARGV[0]\n\n"; #open data for user file open(DBUSER,"$ARGV[1]") || die "Cannot open user : $!"; my @Directory_Of_Users = <DBUSER>; close(DBUSER); foreach $Single_User_Directory (@Directory_Of_Users) { chomp($Single_User_Directory); $Single_User_Directory =~ s/\\/\//g; if(-f "$ARGV[0]") { #If its just a file print "Copying file to $Single_User_Directory - "; copy("$ARGV[0]","$Single_User_Directory"); print "Successful\n"; } elsif(-d "$ARGV[0]") { print "Copying path to $Single_User_Directory - "; mkpath([$ARGV[0], $Single_User_Directory], 1, 0711); print "Successful\n"; find(\&each_file,"$ARGV[0]//"); } else{ die "You Suck JT Archie - there's your motivation..."; } } } else{ print qq~ Usage: perl sendfile.pl <file(s)> <group list> <file(s)> - can either specify a single file or directory NOTE: if not full path to file then assumes in current directory <group list> - text file of directories to send to NOTE: if not full path assumes in current directory ~; } sub each_file{ my $filename = $_; my $filepath = $File::Find::name; if(-f "$filepath") { my $copypath = $filepath; $copypath =~ s/$ARGV[0]/$Single_User_Directory/i; copy("$filepath","$copypath"); } }

$ARGV[0] = a directory with no backslash and $ARGV[1] = a file to the directories I am to copy the "copy" directory to...

"The pajamas do not like to eat large carnivore toasters."
In German: "Die Pyjamas mögen nicht große Tiertoaster essen.
In Spanish: "Los pijamas no tienen gusto de comer las tostadoras grandes del carnívoro."


In reply to copy directories by thealienz1

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.