Hi monks I have written a script to copy files from one directory to another.What I want to do is that I have a tar file which in turn has many tar files inside it .I am extracting the main tar file and then after iterating through all the tar files inside of the big tar file i create folder name based on the tar file for example :for a file named FILE1.tar I create a directory named FILE1.After this I want to copy the FILE1.tar to its respective directory and extract it there.The problem is I am not able to use the move command and my program only creates the directory.Forgot to mention that I get a message file exists when i compile my program.Thanks in advance

#!/usr/bin/perl -w use File::Copy; use strict; use Archive::Tar; my (@files,$i,$name,$ext,@file,$oldlocation,$tobe); my $tar = Archive::Tar->new(); $tar->read('some.tar'); $tar->extract(); @files=<*.tgz>; #print @files; for $i(0..$#files) { $file[$i]=do{local(@ARGV,$/)=$files[$i];<>}; ($name,$ext)=split(/\./,$files[$i]); mkdir("$name",0777)||print $!; $oldlocation="/home/newbie/ta/$file[$i]"; $tobe="/home/newbie/ta/$name/"; move ($oldlocation,$tobe); } exit;

In reply to copy files from one directory to another by luckysing

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.