469,319 Members | 2,324 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,319 developers. It's quick & easy.

copying specific files from a directory

Iam trying to copy specific files listed in code.txt file to another directory
please help to sort out this problem, scriptis running but no out put

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.     use File::Copy cp;
  3.  
  4.     my $movefile;
  5.     my @dirfile, @movelist;
  6.  
  7.     open (MOVELIST, "code.txt");
  8.     my $srcpath = "/home/jawad/perllerning/";
  9.     my $movepath = "/home/jawad/perllerning/cool/";
  10.  
  11.     while () {
  12.     chomp $_;
  13.     push (@movelist, $_);
  14.     }
  15.     foreach $movefile(@movelist){
  16.     $movefile = ".mol2";
  17.  
  18.    # print ".$srcpath$movefile.  . $movepath$movefile.\n;
  19.     cp ($srcpath,$movefile, $movepath,$movefile);
  20.     }
Nov 20 '07 #1
4 1301
numberwhun
3,503 Expert Mod 2GB
I think that you need to really go read the File::Copy page on CPAN.

I see that you don't have the double quotes around "cp" in the use statement, as demonstrated by the help page. Also, you have 4, comma separated options to cp when the page clearly shows that the command only takes two.

I would straighten it out and see if it works.

Regards,

Jeff
Nov 20 '07 #2
Thanks

I correct it but still no output
Nov 20 '07 #3
numberwhun
3,503 Expert Mod 2GB
Can you please post your new code?

Thanks!

Jeff
Nov 20 '07 #4
KevinADC
4,059 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. cp (file1, file2) or die "Can't cp file1 - file2 : $!";
  2.  
change file1 and file2 to the actual files you are trying to cp.
Nov 20 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Robert Tarantino | last post: by
5 posts views Thread by Ian Davies | last post: by
10 posts views Thread by Martin Ho | last post: by
17 posts views Thread by Kerr | last post: by
2 posts views Thread by Jerad Rose | last post: by
2 posts views Thread by Alan Bak | last post: by
18 posts views Thread by mike3 | last post: by
13 posts views Thread by writeson | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.