---
title: "perl faq 学习之复制文件"
author: "zhouzhao21"
date: "2009-04-26T00:04:35Z"
tags: ["HTML", "Perl"]
categories: ["编程语言"]
slug: "perl-faq"
draft: false
lastmod: "2009-04-26T00:05:19Z"
id: 374914
url: "https://kyo-cc.iteye.com/blog/374914"
---

目的：复制文件。

```perl

#!/usr/bin/perl
use warnings;
use File::Copy;

$original = 'test.file';
$new_copy = 'test_copy.file';
# 注意，如果目标文件存在会直接覆盖。
copy($original, $new_copy) or die "Copy failed: $!";
print 'copy over!';

```

one line code on command line :

```command line

perl -MFile::Copy -we "copy(\"test.file\", \"test_copy.file\") or die die \"Copy failed: $!\""

```

 

原文：
<http://faq.perl.org/perlfaq5.html#How_can_I_copy_a_fil>