Use of here document in PERL

Use of here document in PERL

create a file named "perl-tutorial-example-here-document.pl" then copy and paste the below code:

print <<EOF;
Use of here document in PERL.\n
Here it is.\n
EOF

print "\n\n";
print <<'EOF2';
Use of here document in PERL.\n
It is same but another way.\n
EOF2

print "\n\n";
# VARIABLE IN PERL HERE DOCUMENT
$MyVariable="Variable";
print <<EOF_VARIABLE;
Use of here document in PERL.\n
It is the use of $MyVariable in PERL here document.\n
EOF_VARIABLE

Use of here document in PERL

Now run the program (perl-tutorial-example-here-document.pl) from command prompt & get some interesting results as follows:

Use of here document in PERL - output in the windows command prompt

The result in the windows command prompt

No comments:

Post a Comment

leave your comments here..