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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |