Search code examples
perlverification

Print a paragraph in perl by not formatting using escape sequence


I am using a existing Perl subroutine to print a file as following:

sub quit_FRM () {
print STDOUT <<QUIT_IDLE;

##-------------------------------------------------- 
## Quit idle
##--------------------------------------------------
Q idle

QUIT_IDLE

}

By calling this subroutine, it would print on stdout the following:

##-------------------------------------------------- 
## Quit idle
##--------------------------------------------------
Q idle

I have been searching on google for a while but I still had no clue. Can anybody tell me what is "<<" here? and what is "QUIT_IDLE" here? And hopefully I can search on google how to use this feature.

Right, this is a duplicated question, but by searching "perl print << " does not give anything relevant at all, or anything I can think of to describe this question.


Solution

  • This is called a "here document". See <<EOF in perlop.

    It exists in other languages, too:

    http://tldp.org/LDP/abs/html/here-docs.html

    https://en.wikipedia.org/wiki/Here_document