-
Obviously, the programs in the above two positions do not work properly, and the correct one is as follows, push @name dir, $file if (-e"$directory/$file");
Explain,-e file test should be followed by the path that can really query the file (or folder),And the two-digit -e is followed by the file name of a file,So whether this file exists is from the current directory,So the general file can not be found,If you put one or two files with the same file name in the directory where the program is located,It can be printed,So remember,The judgment of this file in perl is only the judgment of whether the file indicated by the path behind -e exists, Add the directory path to the file, and the file will be found, I've tested it, so change it yourself.
There is also a common sense, why a few points are output, in all the folders, there are two files that you usually can't see, and the names of these two folders are "."."And"...They represent the current directory and the upper directory, and exist in all directories, so when you judge, you can judge that these two folders exist and will be printed, and you will slowly understand how easy these two folder names are.
-
I can't test it with your **, I don't know how to learn it, and I haven't found out the reason. I had to use chdir to change the working path and then use glob"* ."to achieve it. Here's my**:
use strict;
use warnings;
use diagnostics;
my $directory="d:/software/windows 7 client software logo toolkit - rtw";
my @name_dir;
my @name_write;
my @name_read;
my @name_executive;
my $file;
my $file_dir;
my $file_read;
my $file_write;
my $file_executive;
chdir "$directory";
foreach $file(glob ".* ")
print"the existed file are:";
foreach$file_dir(@name_dir)
print" the read file are: ";
foreach$file_read(@name_read)
print" the write file are: ";
foreach$file_write(@name_write)
print" the executive file are: ";
foreach$file_executive(@name_executive)
-
No, you can't:
open file1,"1";
open file2,"2";
while(defined($line 1=))} can:
open file1,"1";
while(defined($line 1=))} can be used for nesting.
open f1,"1";
open f2,"2";
a1=;a2=;
for $line1 (@a1)}
-
Okay, aren't you almost writing it out now?
-
Create a list of files, one file name per line.
Read the file name line by line and perform the operation.
-
You can do it in the order you narrate.
Open the file to read the content --> do the corresponding calculation --> close the file to open the result file --> to write the calculation result --> close the result file Repeat the above algorithm, calculate the content of the sum and then append the calculation result to the result file In addition, you can also read the three files separately first, save the settlement result to the three result variables (that is, save it in memory), and then write it to the result file for the last time.
-
In perl, you can use the open or sysopen functions to open the file and operate, both of which need to use a file handle (i.e., a file pointer) to read, write, locate and other operations on the file.
Let's take the open function as an example
Read: open(file handle,"File Name"open(file handle,"File Name"), the premise file must already exist, otherwise it will return 0 with an error message in $!Middle.
Write: open(file handle,"File Name"If the file does not exist, it is created, and if it exists, the content is cleared, and the length is truncated to 0, $!There is an error message.
Append: open(file handle,"File Name"), which is basically the same as the text, but one thing, the content of the file will not be cleared, and the new content will be appended to the original text.
Read/write: open(file handle,"File Name"With the "+" mode, you can read and write files at the same time. You can use the tell() function to move inside the file, and the seek() function to locate it.
If the file doesn't exist, it will be created. If the file already exists, the original data will not be erased.
open(file handle,"File Name"Through the "+" mode, you can read and write files at the same time, but unlike the above, it is a broken write, which will clear the original content.
line=;close(fd);The example above is to open the file and read the contents of the file into the @line, and close the file.
This cannot be deleted.
I don't know why, in win, if it is not installed properly, the folder will appear. >>>More
The compressed file occupies a small space, and the speed will be fast, so many of the network are compressed, and they generally install their own decompression programs, such as winrar >>>More
It's obvious that there is a virus in the USB flash drive! Your computer should have a virus, you type msconfig in the run, and see if there is an xp- (8 16-bit numbers) in the startup itemexe process,If you don't know,You can press a 360 security guard to see the startup item,I'm sure you must have it in your computer.,This thing doesn't seem to be very harmful.。 >>>More
E,F drive does not have system files,Because the system is installed in C drive,If you want to deep empty all system files in E,F,Then you can search in the search。 tmp (regular temporary file);temp (regular temporary file); >>>More
This is the director file, open it with him.