nysus has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use CGI; my $query = new CGI; print <<EOF; <html> <head> </head> <body> Hello. </body> </html> EOF
The above resulted in a Can't find string terminator "EOF" anywhere before EOF at formtest.cgi line 7. Then, on a hunch, I tried:
#!/usr/bin/perl -w use strict; use CGI; my $query = new CGI; &routine; sub routine { print <<EOF; <html> <head> </head> <body> Hello. </body> </html> EOF }
...merely placing the 'Here' document in a subroutine and it worked fine. Can someone please explain this behavior?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Here document outside subroutines
by OeufMayo (Curate) on Apr 02, 2001 at 19:08 UTC | |
by nysus (Parson) on Apr 02, 2001 at 19:10 UTC |