Instructions for using the angle brackets operator (<>) in perl

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.