On Mon, Nov 19, 2001 at 07:15:26PM -0600, Craig A. Berry wrote:
> At 6:57 PM -0500 11/19/01, Michael G Schwern wrote:
> > Something in vmsperl has decided that you always
> >need a newline at the end of a print.
> >
> >$ perl -e "print 'foo'"
> >foo
> >$
>
> As Peter said, it's probably in the terminal driver (or the mailbox
> driver in the case of a pipe). I tried modifying runperl like so:
>
> --- t/test.pl;-0 Thu Nov 15 19:10:54 2001
> +++ t/test.pl Sat Nov 17 15:47:18 2001
> @@ -249,6 +249,7 @@
> }
> my $result = `$runperl`;
> $result =~ s/\n\n/\n/ if $is_vms; # XXX pipes sometimes double these
> + $result =~ s/\n$// if $is_vms; # backquotes always give you \n at the end
> return $result;
> }
That's no good, what if you *did* want the newline on the end?
The problem is there's no way to distinguish between the output of
perl -e "print 'foo'"
and
perl -e "print qq{foo\n}"
which is a big problem. It gets worse because runperl often does:
perl -e "print 'foo'" | perl -e "do something with STDIN"
making it hard to do any filtering of the first perl program, even if
we could come up with an appropriate filter.
Even if we tried something like:
$ perl -e "print 'foo'" > foo.tmp
$ pipe cat foo.tmp | perl -e "print length <STDIN>"
still no good. Even though there's no newline in foo.tmp
$ wc foo.tmp
0 1 3 foo.tmp
the pipe still puts that damned extra newline on the end.
$ pipe cat foo.tmp | wc
1 1 4
Ok... so this looks like it's a terminal thing (seeing as how
redirecting the output to a file didn't produce a trailing newline).
Can't system() and `` just be told not to do it, since there's no
terminal involved?
Kite enthusiasts may wish to take advantage of the brisk breeze from
all my handwaving.
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
"You can't set a generic cow."
-- Randal Schwartz