The <> operators in Perl can be used for the following purposes:
1 if the middle of the angle bracket is a file handle, the angle bracket operator allows you to read the file handle, such as <STDIN>.
2 If the middle of the angle bracket is a search pattern, the angle bracket operator can return a list of files that match the pattern, which is called a glob, such as < *.bat>.
3 A set of angle brackets operator If there is nothing in the middle, it can read the contents of all the files on the command line, and if no file name is given, you can read the standard output.
Take a look at the following code:
Copy Code code as follows:
while (<>) {
Print $_;
}
If you save the above program as example.pl, run the program with the following command line:
Copy Code code as follows:
#perl –w example.pl file1 file2 file3
You can make the operator <> read the contents of the file1, read 1 rows at a time, read the file2, and then read the File3.
If no file is set, the angle bracket operator reads the data from the file handle stdin.