这是Perl学习笔记的第三部分
#!/usr/bin/perl print "=================================================\n"; print "Write2File\n"; print "=================================================\n"; open (f1,">C:/Users/VmUser/Documents/demo1.text"); $text = "LALALA\n"; print f1 $text; $text = "L2L2L2\n"; print f1 $text; close f1; print "=================================================\n"; print "Read from File\n"; print "=================================================\n"; open (f1,"C:/Users/VmUser/Documents/demo1.text"); while(<f1>){ print $_; } close f1; print "=================================================\n"; print "Create Folder\n"; print "=================================================\n"; $newfolder="C:/Users/VmUser/Documents/new1"; if(mkdir($newfolder)){ print "mkdir OK\n"; }else{ print "mkdir Failed\n"; } print "=================================================\n"; print "List Folder's Files \n"; print "=================================================\n"; $filter = "C:/Users/VmUser/Documents/new/*.pl"; @filelist = glob($filter); foreach(@filelist){ print $_ . "\n"; } print "=================================================\n"; print "copy Files \n"; print "=================================================\n"; $f1 = "C:/Users/VmUser/Documents/demo1.text"; $f2 = "C:/Users/VmUser/Documents/demo3.text"; open (f1,$f1); open (f2,$f2); while(<f1>){ print f2 $_; } close f1; close f2; print "=================================================\n"; print "rename Files \n"; print "=================================================\n"; $f1 = "C:/Users/VmUser/Documents/demo1.text"; $f2 = "C:/Users/VmUser/Documents/demo2.text"; if(rename($f1 ,$f2)){ print "rename OK\n"; }else{ print "rename Failed\n"; }