Perl Learning here Documentation

Source: Internet
Author: User

The here documentation mechanism for Perl is derived from the here document mechanism in the UNIX shell.

As in the shell, the here document in Perl is also a row-oriented reference form, requiring a << operator followed by an initial terminating string.

After <<, no spaces can appear.

If the terminating string is not enclosed in quotation marks or double quotation marks, the variable expression is allowed.

If a single quotation mark is added to the terminating string, the variable expression is not executed. The user should insert the first line of text between the first and last terminating strings.

The last terminating string must be on the line, and white space characters are not allowed around.

Unlike the Unix shell, Perl does not allow command substitution in the here document.

On the other hand, if the terminating string is enclosed in anti-quotes, Perl also allows the command to be executed in the here document.

#!/bin/perl $price = 100;

1 Print <<EOF; # No quotes around Terminator EOF is same # as double quotes

2 The price of $price are right. # Variables is expanded

3 EOF

4 print << ' FINIS ';

5 The price of $price are right. # The variable is not expanded # if Terminator are enclosed in a single quotes

6 FINIS

7 print << x 4; # Prints the Line 4 times

8 Christmas is coming! # Blank line was necessary here as terminating string

9 Print << ' END '; # If Terminator is in Backquotes, # would execute UNIX commands

Ten echo Hi there

Echo-n "The Time is"

Date

END

(Output)

2 The price of are right.

5 The price of $price are right.

8 Christmas is coming!

Christmas is coming!

Christmas is coming!

Christmas is coming!

Ten Hi there the time is Fri 3 17:03:46 PST 2000

"Editor: Clouds TEL: (010) 68476606"
Back to Bibliography   previous Section Next One

Here documentation for Perl learning

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.