关于目录的操作|*|<>|opendir |readdir|unlink|find2perl|rename|readlink|oct()|utime

 1 #!/usr/bin/perl
 2 
 3 use strict;
 4 use warnings;
 5 
 6 foreach my $arg(@ARGV)
 7 {
 8     print "one is $arg
";
 9 }
10 
11 # perl t.pl *.txt
12 # one is 1.txt
13 # one is 2.txt
14 
15 my @all_files = glob '*';print "@all_files
";
16 
17 # perl t.pl *.txt
18 # 1.txt 2.txt check.pl t.pl
19 
20 my @all_txt = glob '*.txt';print "@all_txt
";
21 
22 # perl t.pl *.txt
23 # 1.txt 2.txt
24 
25 my @all = </hwfssz5/ST_DIVERSITY/B10K/PUB/USER/yuanjingnan/linkdata/*>;
26 print "@all
";
27 
28 #/XXX/1.txt /XXX/2.txt /XXX/check.pl /XXX/t.pl
29 
30 open TXT,'1.txt';
31 my $readhand = 'TXT';
32 my @line = readline $readhand;print "$line[4]";
33 
34 #·······11111@@##¥¥#……¥%&……%*……&*
35 
36 my $way = '/hwfssz5/ST_DIVERSITY/B10K/PUB/USER/yuanjingnan/linkdata/';opendir DIR,$way;
37 foreach my $file (readdir DIR)
38 {
39     next if $file =~ /^./;print "my fiels has $way$file
";
40 }
41 
42 #my fiels has /hwfssz5/ST_DIVERSITY/B10K/PUB/USER/yuanjingnan/linkdata/2.txt
43 #my fiels has /hwfssz5/ST_DIVERSITY/B10K/PUB/USER/yuanjingnan/linkdata/check.pl
44 #my fiels has /hwfssz5/ST_DIVERSITY/B10K/PUB/USER/yuanjingnan/linkdata/t.pl
45 #my fiels has /hwfssz5/ST_DIVERSITY/B10K/PUB/USER/yuanjingnan/linkdata/1.txt
46 
47 my $successful=unlink glob '3.*';print "$successful
";
48 
49 #1
50 # ls
51 # 1.txt  2.txt  check.pl  t.pl
52 
53 foreach my $file (glob "*.txt")
54 {
55     my $newfile = $file;$newfile =~ s/.txt$/.in/;
56     if (-e $newfile)
57     {
58         warn "this file exists
";
59     }
60     else
61     {
62         print "successful!,$newfile
"
63     }
64 }
65 
66 #successful!,1.in
67 #successful!,2.in
68 
69 my $link = -l 'egg';my $exit = -e 'egg';my $address = readlink 'egg';print "$link	$exit	$address
";
70 
71 #my $perladd= readlink '/usr/bin/perl';print "$perladd
";
72 
73 #1
74 #
75 #2.txt
76 
77 my $eight=345;my $ten= oct($eight);print "$ten
";
78 
79 #229
80 
81 my $user = getpwnam 'yuanjingnan';print "$user
";
82 
83 #1000092
原文地址:https://www.cnblogs.com/yuanjingnan/p/11111482.html