Perl小推车Perl语言学习Perl语言学习

Perl语言学习(八)Perl文件操作

2018-12-10  本文已影响30人  Davey1220

八、Perl文件操作

1、Perl句柄

print "please input the data\n";
my $data = <STDIN>;
print "The data is $data\n";
print "Here is the example\n";
print STDOUT "Here is the example";
use warnings;
my $data1 = "abc";
my $data2 = abc;  ## error
print $data1;
print $data2;

2、打开文件

3、读写文件

4、文件测试运算符

  $myfile = "./test.txt";
  if (-w $myfile){
      print "we can write it\n";
      }
      else {
          print "we can't write it\n";
      }
  print (-s $myfile);
image.png
  $myfile = "./test.txt";
  print (-M $myfile);

参考来源:https://www.jikexueyuan.com/course/2081.html

上一篇 下一篇

猜你喜欢

热点阅读