首页 > 其他 > 详细

Learning Perl 学习笔记

时间:2014-12-26 14:50:16      阅读:257      评论:0      收藏:0      [点我收藏+]

1.文件读写与命令行参数


#!/usr/bin/perl

use strict;


if (@ARGV < 2){

    die  "USAGE: perl $0 inputfile outfile\n";


}


my ($infile) = @ARGV[0];

my ($outfile) = @ARGV[1];


open my $infile_fh,‘‘, "$infile" || die("Can‘t open the file!");

open my $outfile_fh, ‘>>‘, "$outfile"|| die("Can‘t open the file!");


while(<$infile_fh>){

    #chomp;

    print $outfile_fh  $_;

}

close($outfile_fh);

close($infile_fh);


本文出自 “yiyi” 博客,请务必保留此出处http://heyiyi.blog.51cto.com/205455/1596188

Learning Perl 学习笔记

原文:http://heyiyi.blog.51cto.com/205455/1596188

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!