The <> operators in perl can be used as follows:
1) if the angle bracket contains a file handle, the angle bracket operator allows you to read the file handle, such as <STDIN>.
2) If the angle brackets are in the search mode, the angle brackets operator can return a list of objects matching the mode. This is called glob, for example, <*. bat>.
3) If there is nothing in the middle of a set of angle brackets, it can read the content of all files on the command line. If no file name is provided, it can read the standard output.
See the following code:
Copy codeThe Code is as follows: while (<> ){
Print $ _;
}
If you save the above program as Example. pl, run the program using the following command line:
Copy codeThe Code is as follows: # perl-w Example. pl file1 file2 file3
You can use the <> operator to read the content of file1, read one row at a time, read file2, and then read file3.
If no file is set, the angle brackets operator reads data from the file handle STDIN.