vladb has asked for the wisdom of the Perl Monks concerning the following question:
print $text;my $text = qq~ First line Second line ~;
print <<END Hello there! This is a test! END
print <<END Hello there! This is a test! END my $i;
Yet, when I add a ; below the line containing closing END, the error disappears and I can run script well.syntax error at text_delim.pl line 11, near "my " Global symbol "$i" requires explicit package name at text_delim.pl lin +e 11.
Strange thing is, however, that I always assumed there should be no ';' after the closing line/word of the << text delimiter. Since, also a code like this always worked for me (strangely enough, I never noticed or paid much attention to the ';' after the first <<END either):print <<END Hello there! This is a test! END ; my $i;
Could anyone explain me why there should be a ';' in there at all? And also, why is it permissable to place ';' in either of the two places. What's the difference? Thanks.print <<END; Hello there! This is a test! END my $i;
| "There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: alternative text delimiters
by patgas (Friar) on Feb 22, 2002 at 23:12 UTC | |
|
Re: alternative text delimiters
by apprentice (Scribe) on Feb 22, 2002 at 23:30 UTC | |
|
Re: alternative text delimiters
by vladb (Vicar) on Feb 22, 2002 at 19:50 UTC |