Vixual / 83 posts / tags / 31 comments / feed / comments feed /
Search:

如何複製檔案及目錄

use File::Copy;
copy('file1.txt','file2.txt') or die "can't copy: $!\n";

複製目錄

sub copy_dir{
  my $source = $_[0];
  my $target = $_[1];
  use File::Copy;
  opendir(DIR,$source);
  while(my $filename = readdir(DIR)){
    if(-f "$source/$filename")){
      copy("$source/$filename","$target/$filename") or die "can't copy: $!\n";
    }
  }
  close(DIR);
}

參考網頁

  • File::Copy - Copy files or filehandles
  • 收藏至網路書籤: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • del.icio.us
    • Google
    • Live
    • YahooMyWeb
    • MyShare
    • Hemidemi
    • Funp

    您可能會對以下這些文章感興趣

    您對這篇文章的評價:
    1 Star2 Stars3 Stars4 Stars5 Stars (請給予評價)
    Loading ... Loading ...

    沒有任何留言

    發表您的評論

    (您的留言會在審核後才能公開)