MrSnrub has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; print <<"TEXT"; This is a @{[ PrintHereDoc() ]} here-doc. TEXT print "END\n"; # subroutine sub PrintHereDoc { print "print statement inside a "; return 0; }
I want it to print:
This is a print statement inside a here-doc.
...but instead it is printing:
Why is the "print statement inside a" getting printed first? Also, is there a way I can disregard printing the return value of the subroutine?print statement inside a This is a 0 here-doc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Print statements inside a function call in a here-doc don't work
by davido (Cardinal) on Nov 12, 2012 at 22:26 UTC | |
|
Re: Print statements inside a function call in a here-doc don't work
by 2teez (Vicar) on Nov 12, 2012 at 21:30 UTC | |
|
Re: Print statements inside a function call in a here-doc don't work
by CountZero (Bishop) on Nov 12, 2012 at 22:28 UTC | |
|
Re: Print statements inside a function call in a here-doc don't work
by aitap (Curate) on Nov 12, 2012 at 21:39 UTC |