Click to See Complete Forum and Search --> : Perl output Question


Energon
04-05-2001, 02:36 PM
I'm wanting to print many lines of text using this kind of method:

print<<__EOF__
Some text
More text
More...
Yet even more text
__EOF__

like that... but if I have any statements after the __EOF__, it poops out on me... like this:

print<<__EOF__
text
__EOF__
print "last line";

am I missing something somewhere on how to handle this?

Carnel
04-05-2001, 02:46 PM
Originally posted by Energon:
I'm wanting to print many lines of text using this kind of method:

print<<__EOF__
Some text
More text
More...
Yet even more text
__EOF__

like that... but if I have any statements after the __EOF__, it poops out on me... like this:

print<<__EOF__
text
__EOF__
print "last line";

am I missing something somewhere on how to handle this?

Well based on what you wrote there, you're mussing a semi-colon ( ;) after __EOF__ but I'm not sure if that's really the problem.. normall __<somename>__ vars are system ones and it's treading dangerously using them.. but then what do I know? I could be way out in left field.. hope it helps some though.

Energon
04-05-2001, 02:54 PM
well crap... I tried using the semicolon like this:

print<<__EOF__
Test
One
Two
__EOF__
;
print "last line";

and it printed everything but the "last line" part... and you know what it was? The damn print buffer... I really, really hate that thing sometimes... I just needed a newline or flush with the print and it worked...

billyjoeray
04-05-2001, 08:40 PM
___EOF___

Is already perl syntax for the end of the file so when it finds __EOF__ it will stop reading there. You need to use something else to delimit your text block like _EOF_ maybe. Don't name anything with __whatever__ unless you know what you are doing because perl already uses those internally.

Ben Briggs
04-06-2001, 01:57 AM
Try using another multilined string terminator... I like to use 'EOT', which is short for 'End of Text'.

Perl might be interpreting '__EOF__' as 'End of File', and therefore ending the script at that point.

Ben Briggs
04-06-2001, 01:58 AM
Dang billy, you beat me, I was posting mine when you posted :).

YaRness
04-06-2001, 08:04 AM
i usually use 'EOF', just cuz i think it's the only token for that print command that the perl.vim syntax file will correctly highlight.

Salmon
04-06-2001, 04:25 PM
well crap... I tried using the semicolon like this:

print<<__EOF__
Test
One
Two
__EOF__
;
print "last line";


The semicolon goes on the other end.


print<<__EOF__;
Test One
Two
__EOF__

print "last line";

YaRness
04-08-2001, 09:30 AM
interesting.


print<<EOF
foo
bar
baz
EOF
;
print "narf";

works just as well. i'm not sure which i like better though.

Energon
04-08-2001, 04:03 PM
how do you flush the buffer w/o printing a newline? I've tried:

use IO::Handle;

and then using the autoflush stuff, but it doesn't do it... it's like it's being buffered by Linux rather than Perl, but I'm not sure how to make it flush it...

YaRness
04-09-2001, 08:07 AM
"perldoc -q buffer" sez

select((select(OUTPUT_HANDLE), $| = 1)[0]);

though i'm not sure about the newline thing. that's what i used when i needed an immediate print, and it didn't print any extra newlines.